SQL MCQ class 12

Get Most Important MCQ for SQL with answers. These SQL MCQ class 12 are very helpful for all students learning RDBMS, SQL or preparing for CUET, GATE or any IT or Computer Science competitive.

  1. Which of the following is not an SQL command?
    a. Create Database
    b. Create Table
    c. Create Query
    d. Show Table

Show Answer

c. Create Query

  1. A table can have __ foreign keys
    a. 1
    b. 2
    c. Many
    d. Depends on RDBMS

Show Answer

c. Many

  1. In which of the following case DML is not executed?
    a. When new record is added
    b. When existing record is modified
    c. When existing attribute is modified
    d. When records are deleted

Show Answer

c. When existing attribute is modified

  1. Which is the correct difference between Primary key and Foreign key?
    a. A table can have multiple primary key and single foreign key
    b. A primary key cannot ignore NULL value but Foreign key can
    c. A Primary key can have duplicate data but foreign key does not
    d. None of the above

Show Answer

b. A primary key cannot ignore NULL value but Foreign key can

  1. in SQL ‘FROM’ clause is used to
    a. Define source table name while retrieving records
    b. Define Column name while retrieving records
    c. Define Criteria while retrieving records
    d. Define values while inserting records

Show Answer

a. Define source table name while retrieving records

  1. Which if the following is not an SQL aggregate function?
    a. Avg
    b. Max
    c. Count
    d. All are aggregate function

Show Answer

d. All are aggregate function

  1. SQL stands for
    a. Structured Question Language
    b. Structured Query Language
    c. Super Query Language
    d. System Query Language

Show Answer

b. Structured Query Language

  1. Which of the following is not true about DDL ?
    a. The retrieval of information stored in database
    b. The creation of schema object in database
    c. The deletion of schema object
    d. All are not True

Show Answer

a. The retrieval of information stored in database

  1. DELETE FROM Book where Price <= 2000;
    is a _________type of statement
    a. DDL
    b. DML
    c. DCL
    d. None

Show Answer

b. DML

  1. A table can not have more than one UNIQUE keys.
    a. True
    b. False
    c. Depends upon Primary key
    d. Depends upon RDBMS

Show Answer

b. False

  1. For given table ‘emp’ with following columns
    eno, ename, sal, dept, designation
    Select correct statement to display all records of ‘emp’ in descending order of ename and within ascending order of dept.

    a. SELECT * FROM emp ORDER BY ename, dept DESC;
    b. SELECT * FROM emp ORDER BY ename, ORDER BY dept DESC;
    c. SELECT * FROM emp ORDER BY ename DESC, dept;
    d. SELECT * FROM emp WHERE ORDER BY ename, dept DESC;

Show Answer

c. SELECT * FROM emp ORDER BY ename DESC, dept;

  1. Which of the following is not an SQL Constraint?
    a. IS NULL
    b. Primary Key
    c. Default
    d. Check

Show Answer

a. IS NULL

  1. Select correct SQL statement to increase price of books by 10% in book table.
    a. UPDATE book SET price = price*0.1;
    b. UPDATE book SET price = price + price*0.1;
    c. UPDATE book WHERE price = price*0.1;
    d. UPDATE book WHERE price = price + price*0.1;

Show Answer

b. UPDATE book SET price = price + price*0.1;

14. For given table ‘sales’ what will be output of following code
      SELECT Sname FROM sales WHERE Rank > 4 ORDER BY Sname;

a. Sname
    Safiq
b. Sname
    Amber
    Safiq
c. Sname
    Safiq
    Amber
d. SName
    Jagan
    Jakir
   Mohan

Show Answer

a. Sname
    Safiq

  1. Consider the table ‘Student’ given below:
StudentNoClassNameGameGradeSupwGrade1Marks
107SameerCricketBPhotographyA89.78
118SujitTennisAGardeningC78.79
127KamalaSwimmingBPhotographyB55.89
137SudikshaSwimmingCCookingB92.36
148VeerendraTennisBLiteratureC88.20
159DilharanHockeyACookingB67.66

Write SQL command to add a new column DOB (date of birth)
a. Alter table student modify DOB date;
b. Alter table student add DOB date;
c. Alter table student create DOB date;
d. Alter table student new DOB date;

Show Answer

b. Alter table student add DOB date;

  1. For given table student in Q15 list different games offered by school.
    a. Select Game from Student;
    b. Select Unique(Game) from Student;
    c. Select Distinct(Game) from Student;
    d. Select Game from student where Distinct(Game);

Show Answer

c. Select Distinct(Game) from Student;

  1. For given table Library (Bno, Title, Qty, Price) Display list of books with price ranges 150 to 200 and qty should not be null.
    a. Select Title, Price from Library Where Price between 150 Or 200 And qty = NOT NULL
    b. Select Title, Price from Library Where Price between 150 And 200 Or qty = NOT NULL
    c. Select Title, Price from Library Where Price between 150 Or200 And qty IS NOT NULL
    d. Select Title, Price from Library Where Price between 150 And 200 And qty IS NOT NULL

Show Answer

d. Select Title, Price from Library Where Price between 150 And 200 And qty IS NULL

  1. Consider the ‘Club’ (coachid, coachname, sport, dateofapp, pay). List name of all coaches with their date of appointment in descending order.
    a. Select * from club order by dateofapp DESC
    b. Select coachname, dataofapp from club order by dateofapp DESC
    c. Select coachname, dataofapp from club order by dateofapp DSC
    d. Select * from club order by dateofapp DSC

Show Answer

b. Select coachname, dataofapp from club order by dateofapp DESC

  1. An attribute A of datatype varchar(20) has the value “Keshav”. The attribute B of data type char(20) has value “Meenakshi”. How many characters are occupied in attribute A and attribute B?
    a. 20, 6
    b. 6, 20
    c. 9,6
    d. 6,9

Show Answer

b. 6, 20

  1. “Select Distinct Brand From Product;” What does this given query do?
    a. It gives all the tuples having dept_name
    b. It gives the dept_name attribute values of all tuples without repetition
    c. It gives all the dept_name attribute of all the tuples
    d. It gives all the dept_name attribute of all the tuples

Show Answer

b. It gives the dept_name attribute values of all tuples without repetition

  1. Suchita is creating a table Employee with fields eno, ename, salary. She doesn’t want the salary column to be remain unfilled i.e. she wants to make entry in this field mandatory. Which constraint she should use at the time of creating employee table.
    a. Check
    b. Default
    c. Not Null
    d. Primary Key

Show Answer

c. Not Null

  1. Chaman want to change the default value of DISCOUNT in the CUSTOMER table from 10 to 15. Write most appropriate command to do the same.
    a. Alter Table Customer Add Discount int default(15);
    b. Alter Table Customer Modify Discount int Default(15);
    c. Alter Table Customer Change Discount Default from 10 to 15;
    d. All of the above

Show Answer

b. Alter Table Customer Modify Discount int Default(15);

  1. Write a query to display the name of customers whose name contains ‘a’ as third alphabet from customer table (cno, cname, cadd, mobile).
    a. Select cname from customer where cname like ‘%%a’;
    b. Select cname from customer where cname like ‘_ a’;
    c. Select cname from customer where cname like ‘ _ _a%’;
    d. Select * from customer where cname like ‘_ _a’;

Show Answer

c. Select cname from customer where cname like ‘ _ _a%’;

  1. Raju is trying to delete all records of table ‘emp’. For this he wrote:
    DELETE ALL FROM EMP;
    But he is getting error while executing this code. Help him in writing correct code

    a. DELETE FROM EMP;
    b. DELETE * FROM EMP;
    c. DELETE EMP;
    d. DELETE ALL EMP;

Show Answer

a. DELETE FROM EMP;

  1. DROP TABLE Customer;
    Is a __ type of statement

    a. DDL
    b. DML
    c. DCL
    d. TCL

Show Answer

a. DDL

  1. Which of the following is not DDL command?
    a. ALTER
    b. SELECT
    c. CREATE TABLE
    d. DROP

Show Answer

b. SELECT

  1. SQL command used to display the list of tables stored in database
    a. SELECT TABLES
    b. VIEW TABLES
    c. SHOW TABLES
    d. LIST TABLES

Show Answer

c. SHOW TABLES

  1. Which of the following type of table constraints will prevent the entry of duplicate rows?
    a. Unique
    b. Distinct
    c. Primary Key
    d. NULL

Show Answer

a. UNIQUE, c. Primary Key

  1. The default date format followed in SQL is
    a. Dd/mm/yyyy
    b. Mm/dd/yyyy
    c. Yyyy/dd/mm
    d. Yyyy/mm/dd

Show Answer

d. Yyyy/mm/dd

  1. Which of the following is not a valid data type to store alphanumeric data in MySQL?
    a. Char
    b. Varchar
    c. Text
    d. Memo

Show Answer

d. Memo

  1. Which two constraints when applied together will produce a Primary Key constraint?
    a. Foreign Key + Unique Key
    b. NOT NULL + Foreign Key
    c. NOT NULL + Unique Key
    d. Primary Key can not be replaced by combining other constraints

Show Answer

c. NOT NULL + Unique Key

  1. To store Mobile number in a table which data type should be preferred?
    a. Int
    b. Char(n)
    c. Varchar(n)
    d. Float

Show Answer

b. Char(n)

  1. Reena wants to see the the fieldnames and its data type of table ‘department’. What code she should write?
    a. Select * from department;
    b. View department;
    c. Show table department;
    d. Describe department;

Show Answer

d. Describe department;

  1. Jaikaran want to remove primary key assigned to bookid from book table. Help him in writing suitable code.
    a. Drop primary key from book
    b. Alter table book modify bookid drop primary key;
    c. Alter table book drop primary key;
    d. Alter table book drop primary key (bookid);

Show Answer

c. Alter table book drop primary key;

  1. Which of the following is not a valid operator used in SQL to set criteria in query?
    a. IN
    b. LIKE
    c. IS NOT NULL
    d. ==

Show Answer

d. ==

  1. Write SQL command to display name of all employees containing ‘aa’ as a substring in name.
    a. Select name from employee where name like ‘aa%’;
    b. Select name from employee where name like ‘aa%’ ;
    c. Select name from employee where name like ‘%aa%’ ;
    d. Select name from employee where name like ‘_aa’;

Show Answer

c. Select name from employee where name like ‘%aa%’ ;

  1. Supriya has following code to insert a record in table ’salesman’, but getting error. Help her in writing appropriate code.
    INSERT EMP VALUES(‘203’,’RAJU’, ‘DELHI’);

    a. INSERT IN EMP VALUES(‘203’,’RAJU’, ‘DELHI’)’;
    b. INSERT (EMP) VALUES(‘203’,’RAJU’, ‘DELHI’);
    c. INSERT TO EMP VALUES(‘203’,’RAJU’, ‘DELHI’);
    d. INSERT INTO EMP VALUES(‘203’,’RAJU’, ‘DELHI’);

Show Answer

d. INSERT INTO EMP VALUES(‘203’,’RAJU’, ‘DELHI’);

  1. “SELECT * FROM Employee; “ is
    a. DDL
    b. DML
    c. DCL
    d. None of these

Show Answer

a. UNIQUE

  1. DDL stands for
    a. Dynamic Data Language
    b. Database Definition Language
    c. Data Definition Language
    d. Dynamic Database Language

Show Answer

c. Data Definition Language

  1. DML is
    a. Database Manipulation Language
    b. Data Manipulation Language
    c. Data Maintenance Language
    d. Database Maintenance Language

Show Answer

b. Data Manipulation Language

  1. Char(n) and varchar(n) are used to store _ length and variable data
    a. Variable, fixed
    b. Fixed, variable
    c. Equal, equal
    d. None of these

Show Answer

b. Fixed, variable

  1. Which of the following provides the ability to query information from the database and insert
    tuples into, delete tuples from, and modify tuples in the database?

    a. DML(Data Manipulation Language)
    b. DDL(Data Definition Language)
    c. Query
    d. Relational Schema

Show Answer

a. DML(Data Manipulation Language)

7 thoughts on “SQL MCQ class 12”

  1. Pingback: Library Management System in Python | Download Free – techtipnow

  2. Pingback: Hospital Management System in Python | Mini School College Project – techtipnow

  3. Pingback: Inventory Management System in Python | Stock Management System – techtipnow

  4. Q13 ans should have * for multiplication
    Q14 ans not given
    Check Q 18 options are not according to asked ques, ans should contain NOT

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!