SQL Online Quiz


Advertisements


Following quiz provides Multiple Choice Questions (MCQs) related to SQL. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - Consider the following schema −

STUDENTS(student_code, first_name, last_name, email, 
         phone_no, date_of_birth, honours_subject, percentage_of_marks);

Which of the following query would display the distinct honours subjects in the STUDENTS table?

A - select honours_subject from students;

B - select distinct honours_subject from students;

C - select all honours_subject from students;

D - select * from students;

Answer : B

Q 2 - What is returned by SUBSTR(‘TUTORIALS POINT’, 1, 9)?

A - TUTORIAL

B - POINT

C - TUTORIALS

D - UTORIALS

Answer : C

Q 3 - You want to calculate the tax payable by the employees of an organization. If the employee gets a commission, then the tax would be calculated on commission plus salary, if the employee does not get any commission, then the tax would be calculated on salary only. Which function should you use for calculating tax?

A - NVL

B - NVL2

C - NULLIF

D - COALESCE

Answer : B

Q 5 - You want to calculate the minimum percentage of marks obtained under each honours group students, where the minimum marks is more than the minimum marks in economics department. Under which clause should the subquery be?

A - WHERE clause

B - FROM clause

C - HAVING clause

D - None of the above.

Answer : C

Q 7 - Consider the following schema −

LOCATIONS(subject_code, department_name, location_id, city);

Which code snippet will alter the table LOCATIONS and change the datatype of the column CITY to varchar2(30)?

A - ALTER TABLE locations MODIFY COLUMN (city varchar2(30));

B - MODIFY TABLE locations ADD (city varchar2(30));

C - ALTER TABLE locations MODIFY (city varchar2(30));

D - None of the above.

Answer : C

Answer : D

Q 9 - Which of the following code will create an index named

stu_marks_ind on the columns student_code and percentage_of_marks of the STUDENTS table.

Now which will delete the index stu_marks_ind.

Which of the following code will delete an index stu_marks_ind on the columns student_code and percentage_of_marks of the STUDENTS table?

A - drop index stu_marks_ind;

B - delete index stu_marks_ind;

C - drop stu_marks_ind;

D - drop index stu_marks_ind on students;

Answer : A

Q 10 - Which of the following code would allocate the privileges of creating tables and view to the role named student_admin?

A - grant create table, create view to student_admin;

B - grant to student_admin create table, create view;

C - grant role student_admin create table, create view;

D - None of the above.

Answer : A


sql_questions_answers.htm

Advertisements