SQL

  Home  Databases Programming  SQL


“SQL Interview Questions and Answers will guide us now that SQL (Structured Query Language) is a database computer language designed for managing data in relational database management systems (RDBMS), and originally based upon Relational Algebra. So learn SQL or get preparation for the job of SQL (Structured Query Language) with the help of this SQL Interview Questions with Answers guide”



172 SQL Questions And Answers

61⟩ When invoking this procedure, you encounter the error?

When invoking this procedure, you encounter the error:

ORA-000: Unique constraint(SCOTT.THEATER_NAME_UK) violated.

How should you modify the function to handle this error?

1. An user defined exception must be declared and associated with the error code and handled in the EXCEPTION section.

2. Handle the error in EXCEPTION section by referencing the error code directly.

3. Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception.

4. Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement.

 202 views

62⟩ Explain UNION, MINUS, UNION ALL and INTERSECT?

INTERSECT - returns all distinct rows selected by both queries. MINUS - returns all distinct rows selected by the first query but not by the second. UNION - returns all distinct rows selected by either query UNION ALL - returns all rows selected by either query, including all duplicates.

 193 views

65⟩ Read the following code

10. CREATE OR REPLACE PROCEDURE find_cpt

11. (v_movie_id {Argument Mode} NUMBER, v_cost_per_ticket {argument mode} NUMBER)

12. IS

13. BEGIN

14. IF v_cost_per_ticket > 8.5 THEN

15. SELECT cost_per_ticket

16. INTO v_cost_per_ticket

17. FROM gross_receipt

18. WHERE movie_id = v_movie_id;

19. END IF;

20. END;

Which mode should be used for V_COST_PER_TICKET?

1. IN

2. OUT

3. RETURN

4. IN OUT

 212 views

66⟩ How would the developer define this variable using referential datatypes?

A developer would like to use referential datatype declaration on a variable. The variable name is EMPLOYEE_LASTNAME, and the corresponding table and column is EMPLOYEE, and LNAME, respectively. How would the developer define this variable using referential datatypes?

1. Use employee.lname%type.

2. Use employee.lname%rowtype.

3. Look up datatype for EMPLOYEE column on LASTNAME table and use that.

4. Declare it to be type LONG.

 197 views