Computer Science

SQL Basics, DDL & Table Creation MCQs | 25 Practice Questions with Answers | CBSE Class 12 Computer Science

Class 12 · Computer Science

SQL Basics, DDL & Table Creation MCQs (25 Questions)

Practice these multiple-choice questions to strengthen your understanding of SQL Basics, Data Definition Language (DDL), Data Manipulation Language (DML), Data Types, Constraints, and Table Creation. Click Show Answer to reveal the correct answer and explanation.


Q1. What does SQL stand for?

A. Structured Query Language
B. Simple Query Language
C. Standard Question Language
D. Structured Queue Language

Show Answer

Answer: A. Structured Query Language

Explanation: SQL (Structured Query Language) is the standard language used to create, manage, and manipulate relational databases.


Q2. SQL is mainly used to:

A. Design graphics
B. Manage databases
C. Develop operating systems
D. Create animations

Show Answer

Answer: B. Manage databases

Explanation: SQL is used to create databases, retrieve, insert, update, and delete data.


Q3. Which SQL category is used to create and modify database objects?

A. DML
B. DDL
C. DCL
D. TCL

Show Answer

Answer: B. DDL

Explanation: Data Definition Language (DDL) is used to define database structures such as databases and tables.


Q4. Which SQL category is used to insert, update, and delete records?

A. DML
B. DDL
C. DCL
D. TCL

Show Answer

Answer: A. DML

Explanation: Data Manipulation Language (DML) is used to manipulate the data stored in tables.


Q5. Which SQL command creates a new database?

A. NEW DATABASE
B. CREATE DATABASE
C. ADD DATABASE
D. MAKE DATABASE

Show Answer

Answer: B. CREATE DATABASE

Explanation: The CREATE DATABASE statement creates a new database.


Q6. Which SQL command selects a database for use?

A. OPEN DATABASE
B. SELECT DATABASE
C. USE
D. CONNECT

Show Answer

Answer: C. USE

Explanation: The USE command selects the database on which SQL operations will be performed.


Q7. Which command displays all available databases?

A. SHOW DATABASES
B. DISPLAY DATABASES
C. LIST DATABASES
D. SHOW DB

Show Answer

Answer: A. SHOW DATABASES

Explanation: The SHOW DATABASES command displays the list of all databases.


Q8. Which SQL command permanently removes a database?

A. DELETE DATABASE
B. REMOVE DATABASE
C. DROP DATABASE
D. ERASE DATABASE

Show Answer

Answer: C. DROP DATABASE

Explanation: The DROP DATABASE command permanently deletes a database.


Q9. Which command displays all tables in the selected database?

A. SHOW TABLES
B. DISPLAY TABLES
C. LIST TABLES
D. SHOW ALL TABLES

Show Answer

Answer: A. SHOW TABLES

Explanation: The SHOW TABLES command lists all tables in the currently selected database.


Q10. Which SQL command is used to create a table?

A. MAKE TABLE
B. CREATE TABLE
C. NEW TABLE
D. ADD TABLE

Show Answer

Answer: B. CREATE TABLE

Explanation: The CREATE TABLE statement is used to create a new table in the selected database.


Q11. Which SQL command displays the structure of a table?

A. SHOW TABLE
B. DESCRIBE TABLE
C. DESCRIBE
D. VIEW TABLE

Show Answer

Answer: C. DESCRIBE

Explanation: The DESCRIBE (or DESC) command displays the structure of a table, including column names, data types, and constraints.


Q12. Which SQL data type is used to store fixed-length character strings?

A. VARCHAR(n)
B. CHAR(n)
C. INT
D. FLOAT

Show Answer

Answer: B. CHAR(n)

Explanation: CHAR(n) stores fixed-length character strings. If the entered value is shorter than n, spaces are added automatically.


Q13. Which SQL data type is used to store variable-length character strings?

A. CHAR(n)
B. INT
C. VARCHAR(n)
D. DATE

Show Answer

Answer: C. VARCHAR(n)

Explanation: VARCHAR(n) stores variable-length strings up to the specified maximum length.


Q14. Which SQL data type is used to store whole numbers?

A. FLOAT
B. DATE
C. INT
D. CHAR

Show Answer

Answer: C. INT

Explanation: The INT data type stores integer (whole number) values.


Q15. Which SQL data type is used to store decimal values?

A. CHAR
B. FLOAT
C. DATE
D. VARCHAR

Show Answer

Answer: B. FLOAT

Explanation: The FLOAT data type stores real (decimal) numbers.


Q16. Which SQL data type is used to store dates?

A. TIME
B. DATE
C. YEAR
D. DATETIME

Show Answer

Answer: B. DATE

Explanation: The DATE data type stores date values in the format supported by the DBMS.


Q17. Which constraint prevents NULL values in a column?

A. UNIQUE
B. PRIMARY KEY
C. NOT NULL
D. DEFAULT

Show Answer

Answer: C. NOT NULL

Explanation: The NOT NULL constraint ensures that a column must always contain a value.


Q18. Which constraint ensures that all values in a column are different?

A. PRIMARY KEY
B. UNIQUE
C. NOT NULL
D. FOREIGN KEY

Show Answer

Answer: B. UNIQUE

Explanation: The UNIQUE constraint prevents duplicate values in a column.


Q19. Which constraint uniquely identifies each record in a table?

A. UNIQUE
B. NOT NULL
C. PRIMARY KEY
D. DEFAULT

Show Answer

Answer: C. PRIMARY KEY

Explanation: A PRIMARY KEY uniquely identifies every record in a table and cannot contain NULL values.


Q20. Which of the following SQL statements correctly creates a table?

CREATE TABLE Student
(
RollNo INT PRIMARY KEY,
Name VARCHAR(30),
Marks FLOAT
);

A. Correct SQL statement
B. Missing semicolon after CREATE TABLE
C. PRIMARY KEY cannot be used with INT
D. VARCHAR cannot store names

Show Answer

Answer: A. Correct SQL statement

Explanation: This is a valid SQL statement that creates a table named Student with appropriate data types and a primary key.


Q21. Which SQL statement selects the SchoolDB database for use?

A. OPEN SchoolDB;
B. SELECT DATABASE SchoolDB;
C. USE SchoolDB;
D. CONNECT SchoolDB;

Show Answer

Answer: C. USE SchoolDB;

Explanation: The USE statement selects the database on which subsequent SQL commands will be executed.


Q22. Which SQL command displays the names of all tables in the currently selected database?

A. SHOW TABLES;
B. SHOW DATABASES;
C. DESCRIBE TABLES;
D. DISPLAY TABLES;

Show Answer

Answer: A. SHOW TABLES;

Explanation: The SHOW TABLES; command lists all tables present in the selected database.


Q23. Which SQL statement correctly displays the structure of the Student table?

A. SHOW Student;
B. DESCRIBE Student;
C. VIEW Student;
D. SHOW STRUCTURE Student;

Show Answer

Answer: B. DESCRIBE Student;

Explanation: The DESCRIBE (or DESC) command displays the structure of a table, including its columns, data types, and constraints.


Q24. Which of the following SQL statements is correct?

A. CREATE DATABASE SchoolDB;
B. USE SchoolDB;
C. CREATE TABLE Student (...);
D. All of these.

Show Answer

Answer: D. All of these.

Explanation: All the given SQL statements are valid and commonly used while creating and working with databases and tables.


Q25. Which statement about SQL and DDL is correct?

A. SQL is used to communicate with relational databases.
B. DDL commands define the structure of databases and tables.
C. PRIMARY KEY uniquely identifies each record in a table.
D. All of these.

Show Answer

Answer: D. All of these.

Explanation: SQL is the standard language for relational databases. DDL commands create and define database objects, and the primary key uniquely identifies each record.


Answer Key

Q.No. Answer Q.No. Answer Q.No. Answer
1A 10B 19C
2B 11C 20A
3B 12B 21C
4A 13C 22A
5B 14C 23B
6C 15B 24D
7A 16B 25D
8C 17C
9A 18B

Practice Tips

  • Remember the purpose of SQL:
    • SQL (Structured Query Language) is used to create, manage, and manipulate relational databases.
  • Differentiate between SQL command categories:
    • DDL (Data Definition Language) – Defines database structure (e.g., CREATE, DROP).
    • DML (Data Manipulation Language) – Manipulates data stored in tables (e.g., INSERT, UPDATE, DELETE).
  • Revise the commonly used SQL data types:
    • CHAR(n) – Fixed-length character string.
    • VARCHAR(n) – Variable-length character string.
    • INT – Integer values.
    • FLOAT – Decimal values.
    • DATE – Date values.
  • Understand the purpose of SQL constraints:
    • NOT NULL – Does not allow NULL values.
    • UNIQUE – Prevents duplicate values.
    • PRIMARY KEY – Uniquely identifies each record and cannot contain NULL values.
  • Memorize these frequently used SQL commands:
    • CREATE DATABASE
    • USE
    • SHOW DATABASES
    • DROP DATABASE
    • SHOW TABLES
    • CREATE TABLE
    • DESCRIBE / DESC
  • Practice writing simple SQL statements and identifying syntax errors, as SQL syntax-based questions are commonly asked in CBSE board examinations.