Certainly! Here are 50 multiple-choice questions (MCQs) about SQL commands with answers:
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)
Which SQL command is used to retrieve data from a database? a) SELECT b) INSERT c) DELETE d) CREATE
Answer: a) SELECT
Which SQL command is used to add new records to a table? a) INSERT b) UPDATE c) DELETE d) ALTER
Answer: a) INSERT
Which SQL command is used to modify existing records in a table? a) UPDATE b) INSERT c) DELETE d) SELECT
Answer: a) UPDATE
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
What SQL command is used to create a new table? a) CREATE b) INSERT c) SELECT d) UPDATE
Answer: a) CREATE
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
Which SQL command is used to add comments or descriptions to database objects? a) COMMENT b) SELECT c) INSERT d) DELETE
Answer: a) COMMENT
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
Which SQL command is used to remove privileges from a user or role? a) REVOKE b) GRANT c) DELETE d) SELECT
Answer: a) REVOKE
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
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
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
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
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
What SQL command is used to delete an entire table and its data? a) DROP b) DELETE c) TRUNCATE d) REMOVE
Answer: a) DROP
Which DDL command is used to change the name of a table? a) RENAME b) MODIFY c) ALTER TABLE d) UPDATE
Answer: a) RENAME
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
0 Comments