2.      What does the following query do?

SELECT SAL + NVL(COMM,0) FROM EMP;

             This displays the total salary of all employees. The null values in the commission column will be replaced by 0 and added to salary.

 

 

3.      Which date function is used to find the difference between two dates?

             MONTHS_BETWEEN

 

4.      Why does the following command give a compilation error?

DROP TABLE &TABLE_NAME;

             Variable names should start with an alphabet. Here the table name starts with an ‘&’ symbol.

 

5.      What is the advantage of specifying WITH GRANT OPTION in the GRANT command?

             The privilege receiver can further grant the privileges he/she has obtained from the owner to any other user.

 

6.      What is the use of the DROP option in the ALTER TABLE command?

             It is used to drop constraints specified on the table.

 

7.      What is the value of ‘comm’ and ‘sal’ after executing the following query if the initial value of ‘sal’ is 10000?

UPDATE EMP SET SAL = SAL + 1000, COMM = SAL*0.1;

             sal = 11000, comm = 1000

 

8.      What is the use of DESC in SQL?

Answer :

             DESC has two purposes. It is used to describe a schema as well as to retrieve rows from table in descending order.

Explanation :

The query SELECT * FROM EMP ORDER BY ENAME DESC will display the output sorted on ENAME in descending order.

 

9.      What is the use of CASCADE CONSTRAINTS?

             When this clause is used with the DROP command, a parent table can be dropped even when a child table exists.

 

10.  Which function is used to find the largest integer less than or equal to a specific value?

             FLOOR

 

11.  What is the output of the following query?

SELECT TRUNC(1234.5678,-2) FROM DUAL;

             1200

Advertisements