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 1 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
- To improve performance, DBAs generally run _______ command that deals with tables
- Compile
- Analyze
- Expedite
- None of the above
Show answer
Answer: B. Analyze
ANALYZE (and now DBMS_STATS) gathers table and index statistics that the optimizer uses to choose good execution plans.
- This query will delete duplicate records based on deptno
- delete from emp a where rowid != (select max(rowid) from emp b where a.deptno=b.deptno);
- delete from emp a,emp b where a.deptno=b.deptno and a.rowid < b.rowid;
- delete from emp a,emp b where a.deptno=b.deptno and a.rowid < b.rowid + 1;
- None
Show answer
Answer: A. delete from emp a where rowid != (select max(rowid) from emp b where a.deptno=b.deptno);
The correlated subquery keeps the row with the highest ROWID for each deptno and deletes the others. Oracle DELETE cannot join two tables the way options B and C try to.
- _________option of a sequence specifies that the sequence cannot generate more values after reaching its maximum or minimum value.
- NO CYCLE
- CYCLE
- RESTART
- REUSE
Show answer
Answer: A. NO CYCLE
NOCYCLE, the default, stops the sequence at MAXVALUE or MINVALUE. CYCLE wraps back to the start.
- which option we can use to run OS command from SQL Plus script?
- >
- !
- <
- None of the above
Show answer
Answer: B. !
In SQL*Plus on Unix, ! (or HOST) runs an operating system command. On Windows use HOST or $.
- ______ is memory reserved for each process that uses Oracle.
- SGA
- Buffer Cache
- PGA
- Buffer Pool
Show answer
Answer: C. PGA
The Program Global Area (PGA) is private memory for each server process. The SGA is shared by all processes.
- ________ can be easily explained as data about data.
- Outer data
- Metadata
- Link data
- Hyper data
Show answer
Answer: B. Metadata
Metadata is data that describes other data, such as the table and column definitions in the data dictionary.
- How to find tables with primary keys.
- SELECT table_name FROM all_constraints WHERE owner = ‘&&OWNER’ AND key_type = ‘P’
- SELECT table_name FROM all_constraints WHERE owner = ‘&&OWNER’ AND key_type = ‘PRIMARY’
- SELECT table_name FROM all_constraints WHERE owner = ‘&&OWNER’ AND constraint_type = ‘P’
- SELECT table_name FROM all_constraints WHERE owner = ‘&&OWNER’ AND constraint_type = ‘PRIMARY’
Show answer
Answer: C. SELECT table_name FROM all_constraints WHERE owner = ‘&&OWNER’ AND constraint_type = ‘P’
Primary key constraints have CONSTRAINT_TYPE = ‘P’ in ALL_CONSTRAINTS. U is unique, R is foreign key and C is check.
- Which is TRUE for ROWID data type ?
- Binary Data upto 4GB.
- Character data upto 4GB.
- A hexadecimal string representing the unique address of a row in its table.
- Binary data stored in an external file.
Show answer
Answer: C. A hexadecimal string representing the unique address of a row in its table.
A ROWID is the unique address of a row, made of the data object number, file, block and row slot.
- If today is Jan 03rd and the current time is 9 PM, what would be the value of sysdate +2.4
- Jan 04th
- Jan 05th
- Jan 06th
- Jan 07th
Show answer
Answer: C. Jan 06th
2.4 days is 57.6 hours. Jan 3 at 9 PM plus 57.6 hours is about 6:36 AM on Jan 6.
- To kill a session, you need _____ and _______
- rowid,serial
- rownum,serial
- sid,serial
- sid,objectid
Show answer
Answer: C. sid,serial
Kill a session with ALTER SYSTEM KILL SESSION ‘sid,serial#’; using values from V$SESSION.
- The access privileges on a table are stored in _________
- DBA_OBJ_PRIVS
- DBA_OBJECT_PRIVS
- DBA_TAB_PRIVS
- DBA_ALL_PRIVS
Show answer
Answer: C. DBA_TAB_PRIVS
DBA_TAB_PRIVS lists object privileges granted on tables and other objects.
- Which of these is equal to 8 AM tomorrow
- TRUNC(SYSDATE + 1) + 8/24
- TRUNC(SYSDATE + 1) + 8
- (SYSDATE + 1) + 8/24
- (SYSDATE + 1) + 8
Show answer
Answer: A. TRUNC(SYSDATE + 1) + 8/24
TRUNC(SYSDATE + 1) is midnight tomorrow, and adding 8/24 adds eight hours.
- Can a table’s NULL column be made NOT NULL
- NO
- Yes
- Yes, but the column should not have any NULL values
- Yes, but the column should be unique
Show answer
Answer: C. Yes, but the column should not have any NULL values
ALTER TABLE … MODIFY column NOT NULL works only if no existing row has a NULL in that column.
- How can one disable using an index on a table column
- Adding an expression to indexed column
- Table column should be NOT NULL
- Table column should be NULLABLE
- Using the Table column in GROUP BY clause
Show answer
Answer: A. Adding an expression to indexed column
Wrapping an indexed column in an expression, such as col + 0 or UPPER(col), stops the optimizer from using a normal index on it.
- If CHAR data type is used to store variable length strings
- It will save a lot of disk space
- It will waste a lot of disk space
- CHAR type cannot be used to store variable length strings
- None of the above
Show answer
Answer: B. It will waste a lot of disk space
CHAR always pads to its full length, so using it for variable-length data wastes space.
- Using a function on an indexed column
- It will use the index by default
- It will not use the index by default
- It will use the index only if the function index is created
- It will use the index if the function is string related
Show answer
Answer: C. It will use the index only if the function index is created
A function on an indexed column prevents a normal index from being used unless a function-based index exists on that same expression.
- Why is searching for large-table full-table scans critical to SQL tuning?
- They indicate an optimized execution plan.
- They may be able to be tuned to use an index
- The full-table scan should be normalized from the database design
- A full-table scan is always sub-optimal.
Show answer
Answer: B. They may be able to be tuned to use an index
Full scans of large tables are often where an index or a better predicate can cut the work dramatically, though a full scan is not always bad.
- Bit Map Index is suggested for _______ fields
- High Cardinal
- Low Cardinal
- Lengthy
- Char
Show answer
Answer: B. Low Cardinal
Bitmap indexes suit columns with few distinct values, such as status or gender, mostly in reporting databases.
- For faster performance, objects can be pinned in SGA in ________ area
- Buffer Pool
- Buffer Cache
- Shared Pool
- PGA
Show answer
Answer: C. Shared Pool
DBMS_SHARED_POOL.KEEP pins packages and cursors in the shared pool so they are not aged out.
- WHERE clause can be used with TRUNCATE
- Yes
- No
- can’t say
- None of the above
Show answer
Answer: B. No
TRUNCATE always removes every row. To remove only some rows, use DELETE with a WHERE clause.
- What are the different types of privileges
- Object privilege
- Role privilege
- System privilege
- All of these
Show answer
Answer: D. All of these
Oracle privileges are system privileges and object privileges. Roles group privileges together so they can be granted as one unit.
- A user can be assigned several roles and a single role can be granted to several users
- TRUE
- FALSE
Show answer
Answer: A. TRUE
Roles are many-to-many: a user can hold several roles, and one role can be granted to many users.
- Which of the following statement about LOB are true?
- LOB can be stored inside or outside a database
- LOB represnts a datatype used to store large,unstructured data
- Internal LOB is a category of LOB
- all of these
Show answer
Answer: D. all of these
LOBs store large unstructured data. Internal LOBs (BLOB, CLOB, NCLOB) live in the database; BFILEs point to files outside it.
- How to display row number with the records
- Using ROWID in the select statement
- using ROWNUM in the select statement
- Using Sequence
- Using ROWCOUNT in select statement
Show answer
Answer: B. using ROWNUM in the select statement
ROWNUM numbers the rows as they are returned by a query.
- How to display a number value in words where variable sal is of type number?
- TO_CHAR ( TO_DATE(sal,’j’) , ‘JSP’ )
- TO_CHAR(sal)
- TO_CHAR(sal,’WORDS’)
- TO_DATE(TO_CHAR(sal,’JSP’),’j’)
Show answer
Answer: A. TO_CHAR ( TO_DATE(sal,’j’) , ‘JSP’ )
TO_DATE(n, ‘J’) turns the number into a Julian date, and TO_CHAR with ‘JSP’ spells it out. It works for whole numbers from 1 to 5,373,484.
- Referential integrity refers to what?
- The enforced uniqueness of a row in a table
- The enforced uniqueness of a column in a table
- Ensuring that a Foreign Key attribute cannot be NULL
- The enforced synchronization of Primary Key and Foreign Key values
Show answer
Answer: D. The enforced synchronization of Primary Key and Foreign Key values
Referential integrity keeps each foreign key value matched to an existing primary key value, or NULL.
- What are the space requirements for views?
- Views require as much space as all the tables they are created from.
- Views require as much space as would a table that presented the same data.
- Views require the space used to store a few records in various system tables.
- Views do not store data and therefore use no space.
Show answer
Answer: C. Views require the space used to store a few records in various system tables.
A view stores only its query in the data dictionary, so it uses almost no space.
- The following are database privileges
- CREATE PROCEDURE
- CREATE REDOFILES
- CREATE SESSION
- A&C
Show answer
Answer: D. A&C
CREATE PROCEDURE and CREATE SESSION are system privileges. CREATE REDOFILES does not exist.
- A user issued a commit statement on the Oracle database? Which of the following indicates what Oracle must do next?
- wait for the feedback from use to write redo to disk
- save changes made to data in datafile
- eliminate data block from buffer cache to make room for new changes
- Write redo indicating transaction has been committed
Show answer
Answer: D. Write redo indicating transaction has been committed
On COMMIT, the log writer writes the redo, including a commit record, to the online redo log. Changed data blocks are written to datafiles later.
- A user issued an insert statement against the Oracle database. Which of the following choices describes a step that Oracle will execute in support of this statement?
- Write changed records to undo segment
- Make changes to data block in memory
- Parse statement f parse tree already exists in shared pool
- write redo for transaction to datafile
Show answer
Answer: B. Make changes to data block in memory
For an INSERT, Oracle changes the data block in the buffer cache and generates undo and redo. The datafile is written later by the database writer.
- A user issued an select command against the Oracle database. Which of the following choices describes a step that Oracle will execute in support of this statement?
- Acquire locks on table queried
- Write changes to disk
- Fetch data from disk into memory
- Generate redo for statement
Show answer
Answer: C. Fetch data from disk into memory
A query reads blocks from disk into the buffer cache when they are not already there. A plain SELECT takes no row locks and generates no redo.
- When a user process fails, what background process cleans up after it?
- PMON
- SMON
- The Job Queue Processes.
Show answer
Answer: A. PMON
PMON (process monitor) cleans up after a failed user process: it rolls back the transaction, releases locks and frees resources.
- What background process refreshes materialized views?
- PMON
- SMON
- The Job Queue Processes.
Show answer
Answer: C. The Job Queue Processes.
Materialized view refreshes run as scheduled jobs, handled by the job queue processes (CJQ0 and Jnnn).
- Name a tablespace automatically created when you create a database.
- SYSTEM tablespace
- Temporary tablespace
- Permanent Tablespace
Show answer
Answer: A. SYSTEM tablespace
The SYSTEM tablespace (and SYSAUX from 10g) is always created with the database.
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.
