NEW
Font size
WorksheetsREVISION ON SQL
Total questions: 20
Worksheet time: 10mins
Consider the following schema −
LOCATIONS(subject_code, department_name, location_id, city);
A - ALTER TABLE locations ADD (address varchar2(100));
B -
ALTER TABLE locations ADD COLUMN(address varchar2(100));
C -
MODIFY TABLE locations ADD COLUMN (address varchar2(100));
D -
None of the above.
Which of the following is not true about removing rows from a table?
A - You can use a
subquery in a DELETE statement.
B - Specific rows are deleted based on the WHERE clause condition.
C - A statement like, DELETE ,
would cause deletion of the table from the database.
D - All of the above.
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;
Which of the following is true about removing rows from a table?
A -
You remove existing rows from a table using the DELETE statement
B - No rows are deleted if you omit the WHERE clause.
C - You cannot delete rows based on values from another table
D - All of the above
Which of the following is not true about the ALTER TABLE statement?
A - It can add a new row
B - It can add a new column
C - It can modify existing columns
D - It can define a default value for the new column
Which of the following query will result in an error?
A - select dept_id, avg(salary) from employees group by dept_id;
B - select avg(salary) from employees group by dept_id;
C - select dept_id, job_id, avg(salary) from employees group by dept_id, job_id;
D - select dept_id, count(name) from employees;
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 - select student_code, first_name, last_name from students where honours_subject = ‘Eng01’;
B - select student_code, first_name, last_name from students where honours_subject is ‘Eng01’;
C - select student_code, first_name, last_name where honours_subject = ‘Eng01’;
D - select student_code, first_name, last_name from
students;
In which of the following cases a DML statement is executed?
A - When new rows are added to a table
B - When a table is created
C - When a transaction is committed
D - None of the above
Which of the following is not true about the MAX and MIN functions?
A - Both can be used for any data type
B - MAX returns the maximum value
C - MIN returns the minimum value
D – All are true
Which of the following displays the unique values of the column?
SELECT ________ dept_name
FROM instructor;
ALL
DISTINCT
FROM
NAME
The ______ clause allows us to select only those rows in the result relation of the ____ clause that satisfy a specified predicate.
A - Where, from
B - From, select
C - Select, from
D - From, where
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 - Salary*1.1
B - ID
C - WHERE
D - INSTRUCTOR
The ________ clause is used to list the attributes desired in the result of a query.
A - WHERE
B - DISTINCT
C - SELECT
D - FROM
SELECT * FROM employee WHERE salary>10000 AND dept_id=101;
Which of the following fields are displayed as output?
A - Salary, dept_id
B - Employee
C - Salary
D - All the field of employee relation
Which of the following statements 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 = GELLER’;
How to select all data from student table starting the name from letter 'M'?
A - SELECT * FROM student WHERE name LIKE 'M%';
B - SELECT * FROM student WHERE name LIKE '%M%';
C - SELECT * FROM student WHERE name LIKE '%M';
D - SELECT * FROM student WHERE name LIKE '_M%';
The SQL keyword BETWEEN is used:
A - to limit the columns displayed.
B - for ranges.
C - as a wildcard.
D - None of these is correct.
SQL can be used to:
A - create database structures only
B - query database data only
C - modify database data only
D - All of the above can be done by SQL
Find the temperature in increasing order of all cities
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;
Find all the cities whose humidity is 95
A - SELECT city WHERE humidity = 95;
B - SELECT city FROM weather WHERE humidity = 95;
C - SELECT humidity = 95 FROM weather;
D - SELECT city FROM weather;
