Oracle SQL and PL/SQL Fundamentals
Test your knowledge of Oracle SQL functions, joins, subqueries, data types, and PL/SQL block structure including SELECT statements, WHERE clauses, GROUP BY, and various Oracle-specific features like TO_CHAR, TRUNC, ROWID, and date formatting.
Questions
Which section of a PL/SQL block commences with the BEGIN keyword?
- Exception
- Executable
- Declarative
- Anonymous
Which constraint can be defined only at the column level?
- UNIQUE
- NOT NULL
- CHECK
- PRIMARY KEY
Evaluate the SQL statement: SELECT LPAD(salary,10,*) FROM EMP WHERE EMP_ID = 1001; If the employee with the EMP_ID 1001 has a salary of 17000, what is displayed?
- 17000.00
- 17000*****
- **17000.00
- An error statement
SELECT TO_CHAR(1000000, '$99,999.00') SALARY FROM dual What Is the Output?
- NNNNNNN
- ########
- 1000000
- 1000000.00
There are also multiple-column subqueries: Queries that return more than one column from the inner SELECT statement.(T/F)
- True
- False
What is the output in RR format for following dates Date Specified :27-Oct-1995
- 2017
- 1917
- 1900
- 2000
The outer and inner queries can get data from different tables?
- True
- False
Which statement describes the ROWID data type?
- binary data up to 4 gigabytes
- character data up to 4 gigabytes
- a hexadecimal string representing the unique address of a row in its table
- raw binary data of variable length up to 2 gigabytes
What will be the output of following Select 8 from Emp ? Emp table has 10 rows
- No Rows returned
- 10 rows of Emp table
- Error
- 8 is displayed 10 times
Can we abbreviate keywords across lines?e.g. DESCRIBE
- True
- False
Is Century Information is recorded when Oracle data base stores the DATE internally into a table?
- True
- False
What is the correct use of the Trunc command on a date?
- TRUNC=To_Date('09-Jan-02,DD-MON-YY,'YEAR',"Date" from Dual;
- Select TRUNC(To_Date('09-Jan-02,DD-MON-YY,YEAR')) "DATE" from Dual;
- Date =TRUNC(To_DATE('09-Jan-02','DD-MON-YY'),'YEAR'),'YEAR)"DATE: from DUAL;
- SELECT TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') "Date " FROM DUAL;
Which type of join should be written to perform an outer join of tables A and B that returns all rows from B?
- Any outer join
- A left outer join
- A cross join
- A right outer join
How many join conditions should be there to avoid a Cartesian Join for joining three tables?
- 1
- 2
- 3
- None of these
Examine the code given below: SELECT employee_id FROM employees WHERE commission_pct=.5 OR salary > 23000 Which of the following statement is correct with regard to this code?
- It returns employees who have 50% of the salary greater than $23,000:
- It returns employees who have 50% commission rate or salary greater than $23,000:
- It returns employees who have 50% of salary less than $23,000:
- None of the above
Which of the following tasks can be performed by using the TO_CHAR function?
- Convert '10'to 10
- Convert 10 to '10'
- Convert 'TEN' to 10
- Convert a date to a character expression
Which of the following SELECT statements will get the result 'elloworld' from the string 'HelloWorld'?
- SELECT SUBSTR ('HelloWorld',1) FROM dual;
- SELECT LOWER (SUBSTR ('HellowWorld', 2,1) FROM dual;
- SELECT LOWER (SUBSTR('HellowWorld', 2,1) FROM dual;
- SELECT LOWER (TRIM ('H' FROM 'Hello World')) FROM dual;
Where is the GROUP BY clause statement placed in a SELECT statement that includes a WHERE clause?
- Immediately after the SELECT clause
- Before the WHERE clause
- After the ORDER BY clause
- After the WHERE clause
Which operators can be used in an outer join condition?
- =
- OR
- IN
- AND
Evaluate the following SQL statement: SELECT ROUND (TRUNC (MOD (1600, 10),-1), 2) FROM dual; What will be displayed?
- 0
- 1
- 0.00
- An error statement