MCQ of Structured Query Language(SQL) With Answer Set -2


1. Which of the following query is correct for using comparison operators in SQL?

A) SELECT sname, coursename FROM studentinfo WHERE age>50 and <80;

B) SELECT sname, coursename FROM studentinfo WHERE age>50 and age <80;

C) SELECT sname, coursename FROM studentinfo WHERE age>50 and WHERE age<80;

D) None of the above



2.How to select all data from studentinfo table starting the name from letter 'r'?

A) SELECT * FROM studentinfo WHERE sname LIKE 'r%';

B) SELECT * FROM studentinfo WHERE sname LIKE '%r%';

C) SELECT * FROM studentinfo WHERE sname LIKE '%r';

D) SELECT * FROM studentinfo WHERE sname LIKE '_r%';



3. Which of the following SQL query is correct for selecting the name of staffs from 'tblstaff' table where salary is 15,000 or 25,000?

A) SELECT sname from tblstaff WHERE salary IN (15000, 25000);

B) SELECT sname from tblstaff WHERE salary BETWEEN 15000 AND 25000;

C) Both A and B

D) None of the above



4. The SELECT statement, that retrieves all the columns from empinfo table name starting with d to p is ..........................

A) SELECT ALL FROM empinfo WHERE ename like '[d-p]%';

B) SELECT * FROM empinfo WHERE ename is '[d-p]%';

C) SELECT * FROM empinfo WHERE ename like '[p-d]%';

D) SELECT * FROM empinfo WHERE ename like '[d-p]%';



5. Select a query that retrieves all of the unique countries from the student table?

A) SELECT DISTINCT coursename FROM studentinfo;

B) SELECT UNIQUE coursename FROM studentinfo;

C) SELECT DISTINCT coursename FROM TABLE studentinfo;

D) SELECT INDIVIDUAL coursename FROM studentinfo;



6. Which query is used for sorting data that retrieves the all the fields from empinfo table and listed them in the ascending order?

A) SELECT * FROM empinfo ORDER BY age;

B) SELECT * FROM empinfo ORDER age;

C) SELECT * FROM empinfo ORDER BY COLUMN age;

D) SELECT * FROM empinfo SORT BY age;



7. Select the right statement to insert values to the stdinfo table.

A) INSERT VALUES ("15", "Hari Thapa", 45, 5000) INTO stdinfo;

B) INSERT VALUES INTO stdinfo ("15", "Hari Thapa", 45, 5000);

C) INSERT stdinfo VALUES ("15", "Hari Thapa", 45, 5000);

D) INSERT INTO stdinfo VALUES ("15", "Hari Thapa", 45, 5000);



8. How to Delete records from studentinfo table with name of student 'Hari Prasad'?

A) DELETE FROM TABLE studentinfo WHERE sname='Hari Prasad';

B) DELETE FROM studentinfo WHERE sname='Hari Prasad';

C) DELETE FROM studentinfo WHERE COLUMN sname='Hari Prasad';

D) DELETE FROM studentinfo WHERE sname LIKE 'Hari Prasad';



9. Constraint checking can be disabled in existing ............. and .............. constraints so that any data you modify or add to the table is not checked against the constraint.

A) CHECK, FOREIGN KEY

B) DELETE, FOREIGN KEY

C) CHECK, PRIMARY KEY

D) PRIMARY KEY, FOREIGN KEY



10. ..................... joins two or more tables based on a specified column value not equaling a specified column value in another table.

A) OUTER JOIN

B) NATURAL JOIN

C) NON-EQUIJOIN

D) EQUIJOIN


Answers:

1.  B) SELECT sname, coursename FROM studentinfo WHERE age>50 and age <80;
2.  A) SELECT * FROM  studentinfo WHERE sname LIKE 'r%';
3.  A) SELECT sname from tblstaff WHERE salary IN (15000, 25000);
4.  D) SELECT * FROM empinfo WHERE ename like '[d-p]%';
5.  A) SELECT DISTINCT coursename FROM studentinfo;
6.  A) SELECT * FROM  empinfo ORDER BY age;
7.  D) INSERT INTO stdinfo VALUES ("15", "Hari Thapa", 45, 5000);
8.  B) DELETE FROM studentinfo WHERE sname='Hari Prasad';
9. A) CHECK, FOREIGN KEY
10.C) NON-EQUIJOIN

Get 1000's of DBMS MCQs as pdf E-Book on Free Download Now