75+ Important SQL MCQs for Class 12

 





1- What is the full form of SQL?

a) Structured Query Language

b) Structured Query List

c) Simple Query Language

d) None of these

a) Structured Query Language

 

2- Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?

a) Data Definition Language(DDL)

b) Data Manipulation Language(DML)

c) Both of above

d) None

 

c) Both of above

 

3- Which operator performs pattern matching?

a) BETWEEN operator

b) LIKE operator

c) EXISTS operator

d) None of these

 

b) LIKE operator

 

4- What operator tests column for the absence of data?

a) EXISTS operator

b) NOT operator

c) IS NULL operator

d) None of these

 

c) IS NULL operator

 

5- In SQL, which command(s) is(are) used to change a table’s storage characteristics?

a) ALTER TABLE

b) MODIFY TABLE

c) CHANGE TABLE

d) All of the above

 

a) ALTER TABLE

 

6- In SQL, which of the following is not a data definition language commands?

a) RENAME

b) REVOKE

c) GRANT

d) UPDATE

 

d) UPDATE

 

7- In SQL, which command is used to SELECT only one copy of each set of duplicable rows

a) SELECT DISTINCT

b) SELECT UNIQUE

c) SELECT DIFFERENT

d) All of the above

 

a) SELECT DISTINCT

 

8- A command that lets you change one or more fields in a record is

a) Insert

b) Modify

c) Look-up

d) All of the above

 

b) Modify

 

9- Which of the SQL statements is correct?

a) SELECT Username AND Password FROM Users

b) SELECT Username, Password FROM Users

c) SELECT Username, Password WHERE Username = ‘user1’

d) None of these

 

b) SELECT Username, Password FROM Users

 

10- The FROM SQL clause is used to…

a) specify what table we are selecting or deleting data FROM

b) specify range for search condition

c) specify search condition

d) None of these

 

a) specify what table we are selecting or deleting data FROM

 

 

11- Which SQL keyword is used to retrieve only unique values?

a) DISTINCTIVE

b) UNIQUE

c) DISTINCT

d) DIFFERENT

 

c) DISTINCT

 

12- Which SQL keyword is used to retrieve a maximum value?

a) MAXIMUM

b) MOST

c) UPPER

d) MAX

 

d) MAX

 

13- What is a view?

a) A view is a special stored procedure executed when certain event occurs.

b) A view is a virtual table which results of executing a pre-compiled query. A view is not part of the physical database schema, while the regular tables are.

c) A view is a database diagram.

d) None of these

 

b) A view is a virtual table which results of executing a pre-compiled query. A view is not part of the physical database schema, while the regular tables are

 

14- Which of the following SQL commands is used to retrieve data?

a) DELETE

b) INSERT

c) SELECT

d) JOIN

 

c) SELECT

 

15- Which of the following is a SQL aggregate function?

a) LEFT

b) AVG

c) JOIN

d) LEN

 

b) AVG

 

16- Which SQL statement is used to delete data FROM a database?

a) COLLAPSE

b) REMOVE

c) ALTER

d) DELETE

 

d) DELETE 

 

17- Which SQL keyword is used to sort the result-set?

a) SORT BY

b) ORDER

c) ORDER BY

d) SORT

 

c) ORDER BY

 

18- Which of the following group functions ignore NULL values?

a) MAX

b) COUNT

c) SUM

d) All of the above

 

d) All of the above

 

19- What does DML stand for?

a) Different Mode Level

b) Data Model Language

c) Data Mode Lane

d) Data Manipulation Language

d) Data Manipulation Language

 

 

20- The __________clause of SELECT query allows us to select only those rows in the results that satisfy a specified condition.

a) Where

b) from

c) having

d) like

a) Where

 

 

21- Which of the following function is used to FIND the largest value from the given data in MYSQL?

a) MAX ()

b) MAXIMUM ()

c) LARGEST ()

d) BIG ()

a) MAX ()

 

 

22- The data types CHAR (n) and VARCHAR (n) are used to create _______ and _______ types of string/text fields in a database.

a) Fixed, equal

b) Equal, variable

c) Fixed, variable

d) Variable, equal

c) Fixed, variable

 

 

23- The term ___________ is use to refer to a record in a table.

a) Attribute

b) Tuple

c) Row

d) Instance

b) Tuple

 

 

24- Which command is used for cleaning up the environment (sql with Python)?

a) my.close

b) is.close

c) con.close

d) mycon.close

d) mycon.close

 

 

25- A relational database consists of a collection of

a) Tables

b) Fields

c) Records

d) Keys

a) Tables

 

 

26- What is the full form of DDL?

a) Dynamic Data Language

b) Detailed Data Language

c) Data Definition Language

d) Data Derivation Language

c) Data Definition Language

 

 

27- A(n) in a table represents a logical relationship among a set of values.

a) Attribute

b) Key

c) Tuple

d) Entry

c) Tuple

 

 

28- Name the method which is used for displaying only one resultset.

a) fetchmany

b) fetchno

c) fetchall

d) fetchone

d) fetchone

 

 

29- Name the host name used for signing in the database.

a) localhost

b) localpost

c) localcost

d) none of the above

a) localhost

 

 

30- A relational database consists of a collection of

a)Tuples

b) Attributes

c) Relations

d) Keys

c) Relations

 

 

31- Which is the subset of SQL commands used to manipulate database structure including tables?

a) Data Definition Language (DDL)

b) Data Manipulation Language (DML)

c) Both (a) and (b)

d) None

b) Data Manipulation Language (DML)

 

 

32- The term ____________ is used to refer to a field in a table.

a) Attribute

b) Tuple

c) Row

d) Instance

a) Attribute

 

 

33- Consider the following query

SELECT name FROM stu WHERE subject LIKE ‘_______ Computer Science’;

Which one of the following has to be added into the blank space to select the subject which has Computer Science as its ending string?

a) $

b) _

c) ||

d) %

d) %

 

 

34- Consider following SQL statement. What type of statement is this?

SELECT * FROM employee

a) DML

b) DDL

c) DCL

d) Integrity constraint

a) DML

 

 

35- Which of the following function is not an aggregate function?

a) Round()

b) Sum()

c) Count ()

d) Avg ()

a) Round()

 

 

36- Pick the correct username used for logging in database (sql with Python).

a) root

b) local

c) directory

d) host

a) root

 

 

37- Aggregate functions can be used in the select list or the _____ clause of a select statement. They cannot be used in a ______ clause.

a) Where, having

b) Having, where

c) Group by, having

d) Group by, where

b) Having, where

 

 

38- Select correct SQL query from below to find the temperature in increasing order of all cites.

a) SELECT city FROM weather ORDER BY temperature;

b) SELECT city, temperature FROM weather;

c) SELECT city, temperature FROM weather ORDER BY temperature;

d) SELECT city, temperature FROM weather ORDER BY city;

d) SELECT city, temperature FROM weather ORDER BY city;

 

 

39- In SQL, which command is used to SELECT only one copy of each set of duplicable rows

a) SELECT DISTINCT

b) SELECT UNIQUE

c) SELECT DIFFERENT

d) All of the above

a) SELECT DISTINCT

 

 

40- Which of the following is a SQL aggregate function?

a) LEFT

b) AVG

c) JOIN

d) LEN

b) AVG

 

 

41- The command used for modifying the records is:

a) update

b) add

c) updateall

d) none of the above

a) update

 

 

42- An attribute in a relation is foreign key if it is the _________key in any other relation.

a) Candidate

b) Primary

c) Super

d) Sub

b) Primary

 

 

43- Which of the following sublanguages of SQL is used to query information from the data base and to 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

a) DML (Data Manipulation Language)

 

 

 

44- Which of the following is not a legal method for fetching records from database from within Python?

a) fetchone()

b) fetchtwo()

c) fetchall()

d) fetchmany()

b) fetchtwo()

 

 

45- By default, ORDER BY clause lists the results in _______ order.

a) Descending

b) Any

c) Same

d) Ascending

d) Ascending

 

 

46- Which of the following attributes can be considered as a choice for primary key?

a)Name

b)Street

c) Roll No

d) Subject

c) Roll No

 

 

47- In the given query which keyword has to be inserted?

INSERT INTO employee______(1002, “Kausar”, 2000);

a) Table

b) Values

c) Relation

d) Field

b) Values

 

 

48. What SQL statement do we use to display the record of all students whose last name contains 5 letters ending with “A”?

a) SELECT * FROM STUDENTS WHERE LNAME LIKE ‘_ _ _ _A’;

b) SELECT * FROM STUDENTS WHERE LNAME LIKE ‘ _ _ _ _ _’;

c) SELECT * FROM STUDENTS WHERE LNAME LIKE ‘ ????A’;

d) SELECT * FROM STUDENTS WHERE LNAME LIKE ‘*A’;

a) SELECT * FROM STUDENTS WHERE LNAME LIKE ‘_ _ _ _A’;

 

 

49- Consider the table with structure as:

Student (ID, name, dept name, tot_cred)

In the above table, which attribute will form the primary key?

a)Name

b) Dept

c) total_credits

d) ID

d) ID

 

 

50- Which of the following will you use in the following query to display the unique values of the column dept_name?

SELECT _____________ dept_name FROM Company;

a)All

b) From

c) Distinct

d) Name

c) Distinct

 

 

51- Consider the following query:

SELECT name, instructor name, course______id FROM instructor;

To display the field heading course with a different heading as id, which keyword must be used here to rename the field name?

a)From

b) Rename

c) As

d) Join

c) As

 

 

52. With SQL, how do you select all the records from a table named “Students” where the value of the column “FirstName” ends with an “a”?

a) SELECT * FROM Students WHERE FirstName =’a’

b) SELECT * FROM Students WHERE FirstName LIKE ‘a%’

c) SELECT * FROM Students WHERE FirstName LIKE ‘%a’

d) SELECT * FROM Students WHERE FirstName =’%a%’

c) SELECT * FROM Students WHERE FirstName LIKE ‘%a’

 

 

53. The HAVING clause does which of the following?

a) Acts EXACTLY like WHERE clause

b) Acts like a WHERE clause but is used for columns rather than groups.

c) Acts like a WHERE clause but is used form groups rather than rows.

d) Acts like a WHERE clause but is used for rows rather than columns.

c) Acts like a WHERE clause but is used form groups rather than rows.

 

 

54- Which clause is used with “aggregate functions”?

a) GROUP BY

b) SELECT

c) WHERE

d) Both (a) and (b)

a) GROUP BY

 

 

55- To open a connector to Mysql database, which statement is used to connect with mysql?

a) Connector

b) Connect

c) password

d) username

b) Connect

 

 

56- If column “Marks” contains the data set {25, 35, 25, 35, 38}, what will be the output after the execution of the given query?

SELECT MARKS (DISTINCT) FROM STUDENTS;

a) 25, 35, 25, 35, 38

b) 25, 25, 35, 35

c) 25, 35, 38

d) 25, 25, 35, 35

c) 25, 35, 38

 

 

57- Which connector is used for linking the database with Python code?

a) MySQL-connector

b) YesSQL: connector

c) PostSQL: connector

d) None of the above

a) MySQL-connector

 

 

58- If column “Salary” contains the data set {1000, 15000, 25000, 10000, 15000}, what will be the output after the execution of the given query?

SELECT SUM(DISTINCT SALARY) FROM EMPLOYEE;

a)75000

b) 25000

c) 10000

d) 50000

d) 50000

 

 

59- SQL applies conditions on the groups through _____ clause after groups have been formed,

a) Group by

b) With

c) Where

d) Having

d) Having

 

 

60- To execute all the rows from the result set, which method is used?

a) fetchall

b) fetchone

c) fetchmany

d) none of the above

a) fetchall

 

 

61- What is the meaning of “HAVING” clause is SELECT query?

a) To filter out the summary groups

b) To filter out the column groups

c) To filter out the row and column values

d) None of the mentioned

a) To filter out the summary groups

 

 

62- Which of the following queries contains an error?

a) Select * from emp where empid = 10003;

b) Select empid from emp where empid=10006;

c) Select empid from emp;

d) Select empid where empid=1009 and lastname=’GUPTA’;

d) Select empid where empid=1009 and lastname=’GUPTA’;

 

 

63- Which operator tests column for the absence of data (i.e., NULL value) ?

a) EXISTS operator

b) NOT operator

c) IS operator

d) None of these

c) IS operator

 

 

64- Consider the following query:

SELECT name FROM class WHERE subject_____NULL;

Which comparison operator may be used to fill the blank space in above query?

a) =

b) LIKE

c) IS/IS Not

d) if

c) IS/IS Not

 

 

65- Which SQL function is used to count the number of rows in a SQL query?

a) COUNT ()

b) NUMBER ()

c) SUM ()

d) COUNT (*)

d) COUNT (*)

 

 

66- With SQL, how can you return the number of not null record in the Project field of “Students” table?

a) SELECT COUNT (Project) FROM Students

b) SELECT COLUMNS (Project) FROM Students

c) SELECT COLUMNS (*) FROM Students

d) SELECT COUNT (*) FROM Students

a) SELECT COUNT (Project) FROM Students

 

 

67- Which of the following is not an aggregate function?

a) Avg

b) Sum

c) With

d) Min

c) With

 

 

68- All aggregate functions except _______ ignore null values in their input collection.

a) Count (attribute

b) Count (*)

c) Avg

d) Sum

b) Count (*)

 

 

69- Which of the following group functions ignore NULL values?

a) MAX

b) COUNT

c) SUM

d) All of the above

d) All of the above

 

 

70- What will be the order of the data being sorted after the execution of given query

SELECT * FROM STUDENT ORDER BY ROLL_NO;

a)Custom Sort

b) Descending

c) Ascending

d) None of the above

c) Ascending

 

 

71- Where and Having clauses can be used interchangeably in SELECT queries?

a) True

b) False

c) Only in views

d) With order by

b) False

 

 

72- A______ is property of the entire relation, which ensures through its value that each tuple is unique in a relation.

a) Rows

b) Key

c) Attribute

d) fields

b) Key

 

 

73- The operation whose result contains all pairs of tuples from the two relations, regardless of whether their attribute values match.

a) Join

b) Cartesian product

c) Intersection

d) Set difference

b) Cartesian product

 

 

74- Consider following SQL statement. What type of statement is this?

CREATE TABLE employee (name VARCHAR, id INTEGER)

a) DML

b) DDL

c) DCL

d) Integrity constraint

b) DDL

 

 

75- The pattern ‘- – – ’ matches any string of ________ three character. ‘- – – %’ matches any string of ____ three characters.

a) Atleast, Exactly

b) Exactly, Atleast

c) Atleast, All

d) All, Exactly

b) Exactly, Atleast

 

 

 

Also Check:

Computer Science Sample Paper Class 12 Term 2 Set 1

Computer Science Sample Paper Class 12 Term 2 Set 2

Computer Science Sample Paper Class 12 Term 2 Set 3

Computer Science Sample Paper Class 12 Term 2 Set 4

Computer Science Sample Paper Class 12 Term 2 Set 5

Computer Science Sample Paper Class 12 Term 2 set 6

Computer Networking Question and Answer

Important Question Answer for Term 2 Exam

Database Management System Questions with Answer

 

 

Comments are closed.

Copywrite © 2020-2024, CBSE Python,
All Rights Reserved
error: Content is protected !!