Set - 3

Question 1 :

State true or false. EXISTS, SOME, ANY are operators in SQL?

Answer :


Question 2 :

What will be the output of the following query?

Answer :


Question 3 :

What does the following query do?

Answer :

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

Question 4 :

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

Answer :

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

Question 5 :

Which command executes the contents of a specified file?

Answer :

START or @.

Question 6 :

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;?

Answer :

sal = 11000, comm = 1000.

Question 7 :

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

Answer :


Question 8 :

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

Answer :


Question 9 :

What will be the output of the following query?

Answer :

SELECT DECODE(TRANSLATE('A','1234567890','1111111111'), '1','YES', 'NO' );?
Explanation : The query checks whether a given string is a numerical digit.

Question 10 :

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

Answer :


Question 11 :

What operator performs pattern matching?

Answer :

LIKE operator.

Question 12 :

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

Answer :

It is used to drop constraints specified on the table.

Question 13 :

What operator tests column for the absence of data?

Answer :

IS NULL operator.

Question 14 :

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

Answer :

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

Question 15 :

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

Answer :


Question 16 :

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

Answer :

Data Definition Language (DDL).

Question 17 :

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.

Question 18 :

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

Answer :

To copy only the structure, the WHERE clause of the SELECT command should contain a FALSE statement as in the following.
If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied to the new table.

Question 19 :

TRUNCATE TABLE EMP; DELETE FROM EMP; Will the outputs of the above two commands differ?

Answer :

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

Question 20 :

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

Answer :


Question 21 :

What are the wildcards used for pattern matching.?

Answer :

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

Question 22 :

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

Answer :


Question 23 :

What's an SQL injection?

Answer :

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

Question 24 :

What is difference between TRUNCATE & DELETE ?

Answer :

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.

Question 25 :

What is a join? Explain the different types of joins?

Answer :

Join is a query, which retrieves related columns or rows from multiple tables.
Self Join - Joining the table with itself.
Equi Join - Joining two tables by equating two common columns.
Non-Equi Join - Joining two tables by equating two common columns.
Outer Join - Joining two tables in such a way that query can also retrieve rows that do not have corresponding join value in the other table.

Question 26 :

What is the sub-query?

Answer :

Sub-query is a query whose return values are used in filtering conditions of the main query.