SQL Interview Questions -3

21. Which command executes the contents of a specified file?

START or @.


22. 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.


23. Which command displays the SQL command in the SQL buffer, and then executes it?

RUN.


24. What command is used to get back the privileges offered by the GRANT command?

REVOKE.


25. What will be the output of the following query? SELECT DECODE(TRANSLATE('A','1234567890','1111111111'), '1','YES', 'NO' );? NO.

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


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

MONTHS_BETWEEN.


27. What operator performs pattern matching?

LIKE operator.


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

It is used to drop constraints specified on the table.


29. What operator tests column for the absence of data?

IS NULL operator.


30. What are the privileges that can be granted on a table by a user to others?

Insert, update, delete, select, references, index, execute, alter, all.

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

FLOOR.


32. Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?

Data Definition Language (DDL).


33. What is the use of DESC in SQL?

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.


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

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.


35. 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..

36. What is the output of the following query SELECT TRUNC(1234.5678,-2) FROM DUAL;?

1200.


37. What are the wildcards used for pattern matching.?

_ for single character substitution and % for multi-character substitution.


38. What is the parameter substitution symbol used with INSERT INTO command?

&


39. What's an SQL injection?

SQL Injection is when form data contains an SQL escape sequence and injects a new SQL query to be run.

40. What is difference between TRUNCATE & DELETE

TRUNCATE commits after deleting entire table i.e., cannot be rolled back. Database triggers do not fire on TRUNCATE
DELETE allows the filtered deletion. Deleted records can be rolled back or committed. Database triggers fire on DELETE.

courtesy:DEVFYI - Developer Resource - FYI

1 comment:

  1. awesome......hope this is helpful to all viewers.

    ReplyDelete