SQL Online Quiz



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 all the students whose first name starts with the character ‘A’?

A - select first_name from students where first_name like ‘A%’;

B - select first_name from students where first_name like ‘%A’;

C - select first_name from students where first_name like ‘%A%’;

D - select first_name from students where first_name like ‘A’;

Answer : A

Q 2 - What is returned by TRUNC(789.8389, 2)?

A - 789.84

B - 789.83

C - 78

D - 789.00

Answer : B

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 7 - Consider the following schema −

LOCATIONS(subject_code, department_name, location_id, city);

Which code snippet will alter the table LOCATIONS and delete the column named CITY?

A - MODIFY TABLE locations DROP (city varchar2(30));

B - ALTER TABLE locations DROP COLUMN city;

C - ALTER TABLE locations DROP (city);

D - None of the above.

Answer : B

Answer : D

Q 9 - Which of the following minimal code would create a sequence named loc_seq as a primary key of the LOCATIONS table?

A - create sequence loc_seq;

B - create sequence loc_seq on locations;

C - create loc_seq;

D - None of the above.

Answer : A

Q 10 - Which of the following code would grant the role student_admin to a user named william?

A - grant student_admin to william;

B - grant to william student_admin;

C - grant william student_admin;

D - None of the above.

Answer : A

sql_questions_answers.htm
Advertisements