SQL and Database Basics Flashcards
7 cards from real Online Coding Lessons practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 SQL and Database Basics flashcards as text
Which SQL command permanently removes an entire table and all its data from the database?
Answer: DROP TABLE
DROP TABLE permanently deletes the table structure and all its data from the database, unlike DELETE which only removes rows.
What does a foreign key in a database table do?
Answer: Links a column in one table to the primary key of another table
A foreign key establishes a referential relationship between two tables by pointing to the primary key in another (referenced) table.
Which SQL aggregate function calculates the average value of a numeric column?
Answer: AVG()
AVG() is the SQL aggregate function that computes the arithmetic mean of all non-NULL values in a specified numeric column.
What is the correct SQL syntax to select all columns from a table named 'students'?
Answer: SELECT * FROM students
SELECT * FROM students is the correct syntax — the asterisk (*) is a wildcard that means 'all columns.'
In SQL, what does NULL represent?
Answer: The absence of any value
NULL in SQL represents the absence of a value — it means no data was provided for that field, which is different from zero or an empty string.
Which clause in SQL is used to filter groups after a GROUP BY, similar to how WHERE filters rows?
Answer: HAVING
The HAVING clause filters groups created by GROUP BY based on aggregate conditions, while WHERE filters individual rows before grouping.
What type of JOIN returns only the rows that have matching values in both tables?
Answer: INNER JOIN
An INNER JOIN returns only the rows where there is a matching value in both tables, excluding rows that have no match.