SQL Bank
SQL Bank
20. Which constraint ensures that no two rows have the same value?
a) UNIQUE
b) NOT NULL
c) DEFAULT
d) CHECK
Answer: a) UNIQUE
21. What does the NOT NULL constraint ensure?
a) No duplicates
b) Column cannot be NULL
c) Default values are assigned
d) Validates conditions
Answer: b) Column cannot be NULL
22. A Foreign Key is used to:
a) Delete a table
b) Reference a Primary Key in another table
c) Create unique values
d) Sort data
Answer: b) Reference a Primary Key in another table
23. Which constraint ensures a default value?
a) UNIQUE
b) DEFAULT
c) NOT NULL
d) PRIMARY KEY
Answer: b) DEFAULT
51. Which of the following SQL statements is used to retrieve all rows from
a table?
a) SELECT * FROM table_name
b) SELECT table_name
c) FETCH table_name
d) GET table_name
Answer: a) SELECT * FROM table_name
52. To rename a table, which command is used?
a) RENAME TABLE old_name TO new_name
b) ALTER TABLE old_name RENAME TO new_name
c) CHANGE TABLE old_name TO new_name
d) None of the above
Answer: b) ALTER TABLE old_name RENAME TO new_name
53. The DELETE statement without a WHERE clause:
a) Deletes a single row
b) Deletes all rows from the table
c) Displays an error
d) Deletes the table itself
Answer: b) Deletes all rows from the table
54. Which clause is used to sort the result of a query?
a) SORT BY
b) ORDER BY
c) GROUP BY
d) HAVING
Answer: b) ORDER BY
55. To limit the number of rows returned by a query, use:
a) LIMIT
b) WHERE
c) ROWS
d) DISTINCT
Answer: a) LIMIT