wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

REVISION ON SQL

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Consider the following schema −

LOCATIONS(subject_code, department_name, location_id, city);

a)

A - ALTER TABLE locations ADD (address varchar2(100));

b)

B -

ALTER TABLE locations ADD COLUMN(address varchar2(100));

c)

C -

MODIFY TABLE locations ADD COLUMN (address varchar2(100));

d)

D -

None of the above.

2.

Which of the following is not true about removing rows from a table?

a)

A - You can use a

subquery in a DELETE statement.

b)

B - Specific rows are deleted based on the WHERE clause condition.

c)

C - A statement like, DELETE ,

would cause deletion of the table from the database.

d)

D - All of the above.

3.

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)

A - drop index stu_marks_ind;

b)

B - delete index stu_marks_ind;

c)

C - drop stu_marks_ind;

d)

D - drop index stu_marks_ind on students;

4.

Which of the following is true about removing rows from a table?

a)

A -

You remove existing rows from a table using the DELETE statement

b)

B - No rows are deleted if you omit the WHERE clause.

c)

C - You cannot delete rows based on values from another table

d)

D - All of the above

5.

Which of the following is not true about the ALTER TABLE statement?

a)

A - It can add a new row

b)

B - It can add a new column

c)

C - It can modify existing columns

d)

D - It can define a default value for the new column

6.

Which of the following query will result in an error?

a)

A - select dept_id, avg(salary) from employees group by dept_id;

b)

B - select avg(salary) from employees group by dept_id;

c)

C - select dept_id, job_id, avg(salary) from employees group by dept_id, job_id;

d)

D - select dept_id, count(name) from employees;

7.

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 with honours_subject ‘Eng01’?

a)

A - select student_code, first_name, last_name from students where honours_subject = ‘Eng01’;

b)

B - select student_code, first_name, last_name from students where honours_subject is ‘Eng01’;

c)

C - select student_code, first_name, last_name where honours_subject = ‘Eng01’;

d)

D - select student_code, first_name, last_name from

students;

8.

In which of the following cases a DML statement is executed?

a)

A - When new rows are added to a table

b)

B - When a table is created

c)

C - When a transaction is committed

d)

D - None of the above

9.

Which of the following is not true about the MAX and MIN functions?

a)

A - Both can be used for any data type

b)

B - MAX returns the maximum value

c)

C - MIN returns the minimum value

d)

D – All are true

10.

Which of the following displays the unique values of the column?

SELECT ________ dept_name

FROM instructor;

a)

ALL

b)

DISTINCT

c)

FROM

d)

NAME

11.

The ______ clause allows us to select only those rows in the result relation of the ____ clause that satisfy a specified predicate.

a)

A - Where, from

b)

B - From, select

c)

C - Select, from

d)

D - From, where

12.

The query given below will not give an error. Which one of the following has to be replaced to get the desired output?

SELECT ID, name, dept name, salary * 1.1

WHERE instructor;

a)

A - Salary*1.1

b)

B - ID

c)

C - WHERE

d)

D - INSTRUCTOR

13.

The ________ clause is used to list the attributes desired in the result of a query.

a)

A - WHERE

b)

B - DISTINCT

c)

C - SELECT

d)

D - FROM

14.

SELECT * FROM employee WHERE salary>10000 AND dept_id=101;

Which of the following fields are displayed as output?

a)

A - Salary, dept_id

b)

B - Employee

c)

C - Salary

d)

D - All the field of employee relation

15.

Which of the following statements contains an error?

a)

A - Select * from emp where empid = 10003;

b)

B - Select empid from emp where empid = 10006;

c)

C - Select empid from emp;

d)

D - Select empid where empid = 1009 and lastname = GELLER’;

16.

How to select all data from student table starting the name from letter 'M'?

a)

A - SELECT * FROM student WHERE name LIKE 'M%';

b)

B - SELECT * FROM student WHERE name LIKE '%M%';

c)

C - SELECT * FROM student WHERE name LIKE '%M';

d)

D - SELECT * FROM student WHERE name LIKE '_M%';

17.

The SQL keyword BETWEEN is used:

a)

A - to limit the columns displayed.

b)

B - for ranges.

c)

C - as a wildcard.

d)

D - None of these is correct.

18.

SQL can be used to:

a)

A - create database structures only

b)

B - query database data only

c)

C - modify database data only

d)

D - All of the above can be done by SQL

19.

Find the temperature in increasing order of all cities

a)

A - SELECT city FROM weather ORDER BY temperature;

b)

B - SELECT city, temperature FROM weather;

c)

C - SELECT city, temperature FROM weather ORDER BY temperature;

d)

D - SELECT city, temperature FROM weather ORDER BY city;

20.

Find all the cities whose humidity is 95

a)

A - SELECT city WHERE humidity = 95;

b)

B - SELECT city FROM weather WHERE humidity = 95;

c)

C - SELECT humidity = 95 FROM weather;

d)

D - SELECT city FROM weather;