2.            TRUNCATE TABLE EMP;

DELETE FROM EMP;

Will the outputs of the above two commands differ?

             Both will result in deleting all the rows in the table EMP.

 

3.      What is the difference between TRUNCATE and DELETE commands?

             TRUNCATE is a DDL command whereas DELETE is a DML command. Hence DELETE operation can be rolled back, but TRUNCATE operation cannot be rolled back. WHERE clause can be used with DELETE and not with TRUNCATE.

 

4.      What command is used to create a table by copying the structure of another table?

Answer :

             CREATE TABLE .. AS SELECT command

Explanation :

To copy only the structure, the WHERE clause of the SELECT command should contain a FALSE statement as in the following.

CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE 1=2;

If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied to the new table.

5.      What will be the output of the following query?

SELECT REPLACE(TRANSLATE(LTRIM(RTRIM(‘!! ATHEN !!’,’!’), ‘!’), ‘AN’, ‘**’),’*’,’TROUBLE’) FROM DUAL;

             TROUBLETHETROUBLE

 

6.      What will be the output of the following query?

SELECT  DECODE(TRANSLATE(‘A’,’1234567890′,’1111111111′), ‘1’,’YES’, ‘NO’ );

Answer :

             NO

Explanation :

The query checks whether a given string is a numerical digit.

Advertisements