(Structure Query language) MCQ

 Certainly! Here are 50 multiple-choice questions (MCQs) about SQL commands with answers:

  1. What does SQL stand for? a) Structured Query Language (SQL) b) Simple Query Language c) System Query Language d) Structured Question Language

    Answer: a) Structured Query Language (SQL)


  2. Which SQL command is used to retrieve data from a database? a) SELECT b) INSERT c) DELETE d) CREATE

    Answer: a) SELECT

  3. Which SQL command is used to add new records to a table? a) INSERT b) UPDATE c) DELETE d) ALTER

    Answer: a) INSERT

  4. Which SQL command is used to modify existing records in a table? a) UPDATE b) INSERT c) DELETE d) SELECT

    Answer: a) UPDATE

  5. What is the purpose of the SQL DELETE statement? a) To create a new table b) To modify existing records c) To remove records from a table d) To retrieve data from a table

    Answer: c) To remove records from a table

  6. What SQL command is used to create a new table? a) CREATE b) INSERT c) SELECT d) UPDATE

    Answer: a) CREATE

  7. Which DDL command is used to remove all rows from a table while retaining the table structure? a) DELETE b) DROP c) TRUNCATE d) ALTER

    Answer: c) TRUNCATE

  8. Which SQL command is used to add comments or descriptions to database objects? a) COMMENT b) SELECT c) INSERT d) DELETE

    Answer: a) COMMENT

  9. What is the primary purpose of the SQL GRANT statement? a) To add new records to a table b) To modify database schema c) To give specific privileges to a user or role d) To retrieve data from a table

    Answer: c) To give specific privileges to a user or role

  10. Which SQL command is used to remove privileges from a user or role? a) REVOKE b) GRANT c) DELETE d) SELECT

    Answer: a) REVOKE

  11. Which DML command is used to merge data from a source table into a target table based on certain conditions? a) INSERT b) UPDATE c) DELETE d) MERGE

    Answer: d) MERGE

  12. What is the purpose of the SQL CREATE INDEX statement? a) To create a new table b) To retrieve data from a table c) To add comments to database objects d) To create an index on one or more columns

    Answer: d) To create an index on one or more columns

  13. Which SQL command is used to add a new column to an existing table? a) ADD COLUMN b) INSERT c) CREATE TABLE d) ALTER TABLE

    Answer: d) ALTER TABLE

  14. What does DDL stand for? a) Data Design Language b) Data Description Language c) Data Definition Language d) Data Declaration Language

    Answer: c) Data Definition Language

  15. Which SQL command is used to modify the structure of an existing table? a) ALTER TABLE b) CREATE TABLE c) DROP TABLE d) TRUNCATE TABLE

    Answer: a) ALTER TABLE

  16. What SQL command is used to delete an entire table and its data? a) DROP b) DELETE c) TRUNCATE d) REMOVE

    Answer: a) DROP

  17. Which DDL command is used to change the name of a table? a) RENAME b) MODIFY c) ALTER TABLE d) UPDATE

    Answer: a) RENAME

  18. What is the primary purpose of the SQL DROP TABLE statement? a) To remove privileges from a user or role b) To delete all records from a table c) To change the name of a table d) To delete an entire table and its data

    Answer: d) To delete an entire table and its data

  19. Which DDL command is used to add a primary key constraint to a table? a) PRIMARY KEY b) CONSTRAINT c) ADD COLUMN d) ALTER TABLE

    Answer: a) PRIMARY KEY

  20. What SQL command is used to create a new view? a) CREATE INDEX b) CREATE VIEW c) CREATE TABLE d) CREATE DATABASE

    Answer: b) CREATE VIEW

  21. Which SQL command is used to add data to a table? a) ADD DATA b) INSERT INTO c) CREATE RECORD d) ADD RECORD

    Answer: b) INSERT INTO

  22. What is the primary purpose of the SQL COMMENT statement? a) To add comments to SQL queries b) To add comments to database objects for documentation c) To add comments to columns in a table d) To add comments to stored procedures

    Answer: b) To add comments to database objects for documentation

  23. Which SQL command is used to remove all rows from a table without affecting the table structure? a) DELETE b) TRUNCATE TABLE c) DROP d) REMOVE

    Answer: b) TRUNCATE TABLE

  24. What is the purpose of the SQL REVOKE statement? a) To give specific privileges to a user or role b) To create a new table c) To modify existing records d) To remove privileges from a user or role

    Answer: d) To remove privileges from a user or role

  25. Which DDL command is used to rename a column in an existing table? a) RENAME COLUMN b) MODIFY c) ALTER TABLE d) UPDATE COLUMN

    Answer: a) RENAME COLUMN

  26. What is the primary purpose of the SQL COMMENT ON TABLE statement? a) To add comments to database objects for documentation b) To create a new table c) To modify existing records d) To delete a table

    Answer: a) To add comments to database objects for documentation

  27. Which SQL command is used to change the data type of a column in an existing table? a) ALTER COLUMN b) MODIFY c) UPDATE d) CHANGE DATA TYPE

    Answer: a) ALTER COLUMN

  28. What SQL command is used to update records in a table based on certain conditions? a) UPDATE b) INSERT INTO c) DELETE d) MODIFY

    Answer: a) UPDATE

  29. Which DML command is used to merge data from a source table into a target table? a) INSERT b) UPDATE c) DELETE d) MERGE

    Answer: d) MERGE

  30. What is the primary purpose of the SQL CREATE SCHEMA statement? a) To create a new table b) To add comments to database objects c) To group database objects under a common schema d) To retrieve data from a table

    Answer: c) To group database objects under a common schema

  31. Which SQL command is used to add comments to columns in a table? a) COMMENT ON COLUMN b) COMMENT ON TABLE c) ADD COMMENT d) ADD COLUMN COMMENT

    Answer: a) COMMENT ON COLUMN

  32. What does DML stand for? a) Data Definition Language b) Data Description Language c) Data Manipulation Language d) Data Migration Language

    Answer: c) Data Manipulation Language

  33. Which SQL command is used to add a foreign key constraint to a table? a) FOREIGN KEY b) CONSTRAINT c) ADD CONSTRAINT d) ALTER TABLE

    Answer: c) ADD CONSTRAINT

  34. What is the primary purpose of the SQL CREATE SEQUENCE statement? a) To create a new table b) To add comments to database objects c) To generate a sequence of unique numbers d) To retrieve data from a table

    Answer: c) To generate a sequence of unique numbers

  35. Which SQL command is used to retrieve data from multiple tables based on a related column? a) SELECT b) JOIN c) COMBINE d) FETCH

    Answer: b) JOIN

  36. What SQL command is used to add a unique constraint to a column in a table? a) ADD CONSTRAINT b) UNIQUE c) ALTER TABLE d) CREATE CONSTRAINT

    Answer: b) UNIQUE

  37. Which SQL command is used to remove a unique constraint from a column in a table? a) REMOVE CONSTRAINT b) DELETE CONSTRAINT c) ALTER TABLE d) DROP UNIQUE

    Answer: d) DROP UNIQUE

  38. What is the purpose of the SQL ROLLBACK statement? a) To commit a transaction b) To save changes made in a transaction c) To undo changes made in a transaction d) To delete a table

    Answer: c) To undo changes made in a transaction

  39. Which SQL command is used to add or modify records in a table based on a condition? a) MODIFY b) ALTER c) UPDATE d) CHANGE

    Answer: c) UPDATE

  40. What SQL command is used to remove a column from an existing table? a) ALTER TABLE DROP COLUMN b) DELETE COLUMN c) REMOVE COLUMN d) DROP TABLE COLUMN

    Answer: a) ALTER TABLE DROP COLUMN

  41. Which SQL command is used to create a copy of an existing table, including its data and structure? a) DUPLICATE TABLE b) COPY TABLE c) CREATE TABLE d) CLONE TABLE

    Answer: b) COPY TABLE

  42. What is the primary purpose of the SQL COMMIT statement? a) To delete records from a table b) To undo changes made in a transaction c) To commit and save changes made in a transaction d) To create a new table

    Answer: c) To commit and save changes made in a transaction

  43. Which SQL command is used to add a default value to a column in an existing table? a) ADD DEFAULT b) DEFAULT VALUE c) ALTER TABLE SET DEFAULT d) SET DEFAULT

    Answer: c) ALTER TABLE SET DEFAULT

  44. What is the primary purpose of the SQL SAVEPOINT statement? a) To add comments to columns in a table b) To create a new table c) To group database objects under a common schema d) To set a point within a transaction for later rollback

    Answer: d) To set a point within a transaction for later rollback

  45. Which SQL command is used to rename a table in a database? a) ALTER TABLE RENAME b) RENAME TABLE c) RENAME d) UPDATE TABLE NAME

    Answer: b) RENAME TABLE

  46. What is the purpose of the SQL GRANT statement? a) To delete all records from a table b) To add comments to database objects c) To give specific privileges to a user or role d) To retrieve data from a table

    Answer: c) To give specific privileges to a user or role

  47. Which SQL command is used to remove a primary key constraint from a table? a) REMOVE CONSTRAINT b) DELETE CONSTRAINT c) ALTER TABLE d) DROP PRIMARY KEY

    Answer: a) REMOVE CONSTRAINT

  48. What is the primary purpose of the SQL DENY statement? a) To give specific privileges to a user or role b) To remove privileges from a user or role c) To modify existing records d) To add comments to database objects

    Answer: b) To remove privileges from a user or role

  49. Which SQL command is used to add a check constraint to a column in a table? a) CHECK CONSTRAINT b) ADD CONSTRAINT c) ALTER TABLE d) CREATE CONSTRAINT

    Answer: a) CHECK CONSTRAINT

  50. What is the primary purpose of the SQL RENAME statement? a) To change the name of a table b) To add a new column to an existing table c) To remove a table from the database d) To create a copy of an existing table

    Answer: a) To change the name of a table

Post a Comment

0 Comments