Oracle SQL and database questions: views, indexes, joins and subqueries, NULL handling, functions, privileges and roles, tuning and architecture. This set has 34 multiple-choice questions, each with a short explanation (set 2 of 2). Click Start quiz to answer one question at a time and get instant feedback, or use Study mode to read every question with its answer.
All 34 questions with answers
- How can you enable a trace for a session 1) DBMS_SESSION.SET_SQL_TRACE; 2) ALTER SESSION SET SQL_TRACE = TRUE; 3) FND_SESSION.SET_SQL_TRACE;
- 1
- 2
- 1 & 2
- 2,3
Show answer
Answer: C. 1 & 2
Both DBMS_SESSION.SET_SQL_TRACE(TRUE) and ALTER SESSION SET SQL_TRACE = TRUE enable tracing. FND_SESSION.SET_SQL_TRACE does not exist.
- You cannot grant privileges on remote objects to other users.
- TRUE
- FALSE
Show answer
Answer: A. TRUE
You cannot GRANT privileges on objects in a remote database through a database link.
- is a database structure that provides quick lookup of data in a column or columns of a table.
- PRIMARY KEYS
- UNIQUE KEY
- INDEX
- Option 1 & Option 2
Show answer
Answer: C. INDEX
An index is a separate structure that gives fast lookup of rows by the values of one or more columns.
- A —- is a specific representation of data from one or more tables
- Synonym
- Views
- collections
- Recordset
Show answer
Answer: B. Views
A view is a stored query that presents data from one or more tables.
- Maximum number of columns that can be defined in a view
- 1000
- 512
- same as for a table
- Option 1,3
Show answer
Answer: D. Option 1,3
A view can have up to 1,000 columns, the same limit as a table (4,096 in Oracle 23ai).
- what is true about inline views
- Inline view is a subquery that appears in the from clause of the select statement
- Inline view is enclosed in parenthesis and may be given an alias name.
- The columns selected in the inline view can be referenced in the parent query
- All of the above
Show answer
Answer: D. All of the above
An inline view is a subquery in the FROM clause, written in parentheses, often with an alias, and its columns can be used by the outer query.
- For a view to be inherently updatable,which of the following conditions must be met?
- Each column in the view must map to a column of a single table
- if an inherently updatable view contains pseudocolumns or expressions, then you cannot update base table rows with an UPDATE statement that refers to any of these pseudocolumns or expressions
- the select statement should not contains a DISTINCT operator
- All of the above
Show answer
Answer: D. All of the above
An updatable view maps each column to one base table and has no DISTINCT, GROUP BY, aggregates or set operators. Expression columns cannot be updated.
- Which is not a pseudocolumns?
- ROWNUM
- ROWID
- NEXTVAL
- ROWCOUNT
Show answer
Answer: D. ROWCOUNT
ROWNUM, ROWID, NEXTVAL, CURRVAL and LEVEL are pseudocolumns. ROWCOUNT is a cursor attribute (%ROWCOUNT), not a pseudocolumn.
- What is a nested subquery?
- It’s a subquery in the FROM clause with an alias that can be used as a view within the SQL statement
- The subquery used in WHERE clause
- The subquery used in WHERE clause and it refers to any column in the parent statement
Show answer
Answer: B. The subquery used in WHERE clause
A nested subquery sits in the WHERE clause and runs on its own, independent of the outer query.
- What is a correlated subquery?
- It’s a subquery in the FROM clause with an alias that can be used as a view within the SQL statement
- The subquery used in WHERE clause
- The subquery used in WHERE clause and it refers to any column in the parent statement
Show answer
Answer: C. The subquery used in WHERE clause and it refers to any column in the parent statement
A correlated subquery refers to columns of the outer query, so it is evaluated once for each outer row.
- Which statement is correct?
- GRANT UPDATE ON CUSTOMER (title,address) TO ANDREW;
- GRANT UPDATE (title,address) ON CUSTOMER TO ANDREW;
- GRANT UPDATE ON customer COLUMNS(title,addres) TO Adrew
- GRANT UPDATE ON customer.title,customer.address TO Adrew;
Show answer
Answer: B. GRANT UPDATE (title,address) ON CUSTOMER TO ANDREW;
Column-level grants list the columns right after the privilege: GRANT UPDATE (title, address) ON customer TO andrew;
- MERGE command is a combination of?
- INSERT & UPDATE
- INSERT & DELETE
- UPDATE & DELETE
- None of these
Show answer
Answer: A. INSERT & UPDATE
MERGE updates rows that match and inserts rows that don’t. From 10g it can also delete matched rows.
- What does the below statement does? select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
- Dispalys odd number of records
- Give runtime error
- Get execution error
- Display all records in table emp.
Show answer
Answer: A. Dispalys odd number of records
MOD(ROWNUM, 2) is 1 for rows 1, 3, 5 and so on, so the query returns the odd-numbered rows.
- Which date function returns a number value
- ADD_MONTHS
- MONTHS_BETWEEN
- NEXT_DAY
- ROUND
Show answer
Answer: B. MONTHS_BETWEEN
MONTHS_BETWEEN returns a number. ADD_MONTHS, NEXT_DAY and ROUND on a date return dates.
- Omitting the WHERE clause of an UPDATE or DELETE statement has what effect?
- All rows in the specified table are affected
- The query returns an error because the WHERE clause is required.
- Only the current row is affected.
- Only the rows with the correct data type are affected
Show answer
Answer: A. All rows in the specified table are affected
Without a WHERE clause, UPDATE and DELETE act on every row in the table.
- What statement could you use in the WHERE clause to select all the rows in a table where no price is defined
- WHERE price IS NOT NULL
- WHERE price IS < 0
- WHERE price IS NULL
- WHERE price != 0
Show answer
Answer: C. WHERE price IS NULL
Missing values are stored as NULL, and NULL can only be tested with IS NULL.
- Which of the following is not a aggregate functions?
- SUM
- ABS
- COUNT
- MAX
Show answer
Answer: B. ABS
ABS is a single-row function. SUM, COUNT and MAX are aggregate functions.
- How many rows the table DUAL has
- No rows
- Multiple
- one row
- DBA creates the table and inserts rows as needed
Show answer
Answer: C. one row
DUAL has exactly one row and one column (DUMMY = ‘X’).
- RTRIM function is used to
- elimiate leading spaces
- eliminate trailing spaces
- to trim a string to a given length
- not a valid function
Show answer
Answer: B. eliminate trailing spaces
RTRIM removes characters, spaces by default, from the right end of a string.
- LTRIM function is used to
- elimiate leading spaces
- eliminate trailing spaces
- to trim a string to a given length
- not a valid function
Show answer
Answer: A. elimiate leading spaces
LTRIM removes characters, spaces by default, from the left end of a string.
- TRIM function is used to
- elimiate leading spaces
- eliminate trailing spaces
- to trim a string to a given length
- eliminate both leading and trailing spaces
Show answer
Answer: D. eliminate both leading and trailing spaces
TRIM removes leading and trailing spaces (or another given character).
- What can you do to ignore the time portion of a DATE variable
- TRUNC
- TRIM
- SUBSTR
- A&D
Show answer
Answer: A. TRUNC
TRUNC(date) sets the time part to midnight, so comparisons ignore the time.
- IS NULL operator is used
- when checking for NULL values
- not a valid command
- when checking for an empty string
- is equal to comparing with ”
Show answer
Answer: A. when checking for NULL values
IS NULL checks for NULL. In Oracle an empty string ” is NULL, but = ” never returns TRUE.
- Which of these are conversion functions
- TO_DATE
- TO_NUMBER
- TO_CHAR
- All of the above
Show answer
Answer: D. All of the above
TO_DATE, TO_NUMBER and TO_CHAR are all conversion functions.
- Converts either a number or a date to a character string
- TO_CHAR
- TO_DATE
- TO_NUMBER
- TO_VARCHAR
Show answer
Answer: A. TO_CHAR
TO_CHAR converts a number or a date into a character string.
- Expression TRUE AND NULL evaluates to
- TRUE
- FALSE
- NULL
- RAISES syntax eror
Show answer
Answer: C. NULL
TRUE AND NULL is NULL, because the result depends on the unknown value.
- Expression TRUE OR NULL evaluates to
- TRUE
- FALSE
- NULL
- RAISES syntax eror
Show answer
Answer: A. TRUE
TRUE OR anything is TRUE, so TRUE OR NULL is TRUE.
- Which is the right way of dealing with NULL values
- x=NULL
- x IS NULL
- x=”
- x=’ ‘
Show answer
Answer: B. x IS NULL
NULL can only be tested with IS NULL or IS NOT NULL. x = NULL is never true.
- TO_CHAR(SYSDATE,’Mon’) results if the sysdate is 12-JAN-2009
- JAN
- Jan
- JANUARY
- 9-Jan
Show answer
Answer: B. Jan
The case of the format is copied: ‘Mon’ gives Jan, ‘MON’ gives JAN and ‘Month’ gives January.
- Which of the below is a DML statement
- INSERT
- UPDATE
- DELETE
- All of the above
Show answer
Answer: D. All of the above
INSERT, UPDATE and DELETE (and MERGE) are DML statements.
- DDL statements means
- Data definition language
- Data dictionary language
- Data driven language
Show answer
Answer: A. Data definition language
DDL stands for Data Definition Language: CREATE, ALTER, DROP, TRUNCATE and so on.
- Which statement will implicitly issue a commit
- DELETE
- INSERT
- TRUNCATE
- ROLLBACK
Show answer
Answer: C. TRUNCATE
TRUNCATE is DDL, so it commits implicitly. INSERT and DELETE wait for an explicit COMMIT.
- Which of these are Pseudo columns
- ROWNUM
- NEXTVAL
- ROWID
- All of the above
Show answer
Answer: D. All of the above
ROWNUM, NEXTVAL and ROWID are all pseudocolumns.
- Functionality of Right OUTER JOIN is same as right join. Is this statement true?
- No
- Yes
Show answer
Answer: B. Yes
RIGHT JOIN and RIGHT OUTER JOIN are the same; the word OUTER is optional.
More Oracle practice questions
These questions come from interview and training material collected over years of Oracle EBS project work by Amol Jadhav. They are not copied from Oracle certification exams.
