Which SQL keyword is used to retrieve data from a database?
A
GET B
FETCH C
SELECT D
RETRIEVE
Analysis & Theory
The SELECT statement is used to query and retrieve data.
How do you select all columns from a table named 'employees'?
A
SELECT * FROM employees; B
GET ALL FROM employees; C
SELECT ALL FROM employees; D
FETCH * FROM employees;
Analysis & Theory
The * wildcard selects all columns: SELECT * FROM table_name;
Which clause is used to filter rows in a SQL query?
A
ORDER BY B
WHERE C
GROUP BY D
HAVING
Analysis & Theory
The WHERE clause filters rows before grouping or ordering.
What does the ORDER BY clause do?
A
Filters rows B
Deletes rows C
Sorts the result set D
Groups rows
Analysis & Theory
ORDER BY sorts the results in ascending or descending order.
How do you sort results in descending order by column 'salary'?
A
ORDER salary DESC; B
ORDER BY salary DESC; C
SORT BY salary DESC; D
ORDER salary DESCENDING;
Analysis & Theory
The syntax is ORDER BY column_name DESC;
Which statement inserts a new row into the 'products' table?
A
ADD INTO products VALUES (...); B
INSERT INTO products VALUES (...); C
CREATE ROW products (...); D
NEW ROW INTO products (...);
Analysis & Theory
INSERT INTO ... VALUES (...) is the correct syntax for inserting data.
What keyword updates existing records?
A
MODIFY B
UPDATE C
CHANGE D
SET
Analysis & Theory
UPDATE is used to modify existing records in a table.
Which SQL clause groups rows sharing the same values?
A
ORDER BY B
GROUP BY C
HAVING D
WHERE
Analysis & Theory
GROUP BY aggregates rows based on shared column values.
How do you delete all rows in a table 'logs' but keep the table structure?
A
DROP TABLE logs; B
REMOVE TABLE logs; C
DELETE FROM logs; D
ERASE logs;
Analysis & Theory
DELETE FROM table deletes all rows but keeps the table intact.
Which clause filters grouped rows after aggregation?
A
WHERE B
GROUP BY C
HAVING D
ORDER BY
Analysis & Theory
HAVING filters groups created by GROUP BY, whereas WHERE filters individual rows.