ch12SQL Commands
ch12SQL Commands
ch12SQL Commands
A. (Q1 to Q20) There are four options against each question. Choose the
option which you consider the most appropriate as your answer.
1
(C) Ternary
(D) Quaternary
8. Which of the following operation is used if we are interested in only certain
columns of a table?
(A) PROJECTION
(B) SELECTION
(C) UNION
(D) JOIN
9 Which of the following is a valid SQL type?
(A) CHARACTER
(B) NUMERIC
(C) FLOAT
(D) All of the above
10. The RDBMS terminology for a row is
(A) tuple.
(B) relation.
(C) attribute.
(D) degree.
11. Create table is
a) DDL Command
b) DML command
c) DCL Command
d) None of these
2
b) Alter
c) Drop
d) None of these
19. Which one is correct SQL command from selecting the name of employees from
emp table where salary is 10000 and 20000?
a) select name from emp where salary =10000 and 20000;
b) select name from emp where salary between10000 and 20000;
c) select name from emp where salary IN(10000,20000);
d) None of these
20. Select the right statement for inserting record in student table
a) INSERT student values(.................)
b) INSERT values(................)
c) INSERT INTO student values (....................)
d) INSERT values INTO student (..................)
3
d) Write an SQL command to display the number of records from student table.
e) Write an SQL command to display the list of students from student table in
ascending order to their name.
1. Consider the following tables CARDEN and CUSTOMER and answer (b) and (c)
parts .
2. Study the following tables EMPLOYEE and SALARY and write SQL commands for
the question (i) to (iv) and give output for SQL queries (v) to (viii)
4
Relation: Employee
Relation: SALARY
5
i. (i) Display the name of all CA’s who are working in sales department.
ii. (ii) Display the number of employee in finance department.
iii. (iii) Increase the salary of all female employee by 2000.
iv. (iv) Display the average salary given to the employee in each department (ID).
v.
vi. (v) SELECT DEPT, COUNT(*) FROM EMPLOYEE GROUP BY DEPT
vii. (vi) SELECT MIN(SALARY+ ALLOWANCE) FROM SALARY
viii. (vii) SELECT DISTINCT QUALF FROM Employee
(viii) SELECT NAME FROM EMPLOYEE WHERE YEAR(DOJ)<2002
3. Consider the following tables Consignor and Consignee. Write SQL commands for
the statements (i) to (iv) and give outputs for SQL queries (v) to (viii).
TABLE : CONSIGNOR
TABLE : CONSIGNEE
6
(vi) SELECT A.CnorName, B.CneeName
FROM Consignor A, Consignee B
WHERE A.CnorID = B.CnorlD AND B.CneeCity = ‘Mumbai’;
4. Consider the following EMPLOYEE tables. Write SQL queries for (i) to (vi) and find
outputs for SQL queries (vii) to (x).
Table : EMPLOYEE
(i) To display Eno, Name, Gender from the table EMPLOYEE in ascending order of
Eno.
(ii) To display the Name of all the MALE employees from the table EMPLOYEE.
(iii) To display the Eno and Name of those employees from the table EMPLOYEE who
are born between ‘1987-01-01’ and ‘1991-12-01’.
(iv) To count and display FEMALE employees who have joined after ‘1986-01-01’.
(v) To display the details of those employees from employee table whose date of
Joining is in the year 2002
(vi) To count and display the unique DCODE from the table employees
5. Write the SQL commands for (i) to (iv) on the basis of the table HOSPITAL.
7
TABLE: HOSPITAL
Write output for the following SQL commands for Hospital Table.
--------------