SQL and Database Querying Flashcards
6 cards from real DA practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 SQL and Database Querying flashcards as text
What is a primary key in a relational database?
Answer: A column that uniquely identifies each row
A primary key uniquely identifies each record in a table and cannot contain NULL or duplicate values.
Which SQL clause limits the number of rows returned by a query?
Answer: All of the above (syntax varies by database)
Different databases use different syntax: LIMIT (MySQL/PostgreSQL), TOP (SQL Server), or ROWNUM (Oracle) to restrict the number of returned rows.
What does the COALESCE function do in SQL?
Answer: Returns the first non-NULL value in a list
COALESCE evaluates its arguments in order and returns the first non-NULL value, making it useful for handling missing data.
What is a CTE (Common Table Expression) in SQL?
Answer: A temporary named result set defined within a WITH clause
A CTE is a temporary, named result set created with the WITH keyword that can be referenced within the same query.
Which SQL aggregate function returns the highest value in a column?
Answer: MAX()
MAX() returns the largest value in the specified column, and works with numeric, date, and string data types.
What is the difference between DELETE and TRUNCATE in SQL?
Answer: DELETE can include a WHERE clause; TRUNCATE removes all rows without logging individual deletions
DELETE removes specific rows using a WHERE filter and logs each deletion; TRUNCATE removes all rows quickly without row-by-row logging.