Oracle SQL Oracle SQL DDL and Schema Objects 1 — Questions and Answers
Question 1: Which Oracle SQL constraint ensures no two rows in a table have the same value in a column?
- PRIMARY KEY
- UNIQUE (Correct answer)
- NOT NULL
- CHECK
Correct answer: UNIQUE
A UNIQUE constraint prevents duplicate values in a column or combination of columns, but unlike PRIMARY KEY, it allows NULL values.
Question 2: What does the CASCADE option do in DROP TABLE in Oracle SQL?
- Backs up the table before dropping
- Drops the table and all dependent foreign key constraints (Correct answer)
- Drops related tables too
- Forces the drop even if rows exist
Correct answer: Drops the table and all dependent foreign key constraints
DROP TABLE ... CASCADE CONSTRAINTS removes the table along with all foreign key constraints that reference it.
Question 3: Which Oracle SQL statement modifies the structure of an existing table?
- MODIFY TABLE
- UPDATE TABLE
- ALTER TABLE (Correct answer)
- CHANGE TABLE
Correct answer: ALTER TABLE
ALTER TABLE is used to add, modify, or drop columns and constraints in an existing table without recreating it.
Question 4: Which Oracle SQL object automatically generates unique sequential numbers?
- AUTO_INCREMENT column
- SEQUENCE (Correct answer)
- TRIGGER
- ROWNUM
Correct answer: SEQUENCE
A SEQUENCE is a database object that generates unique integer values, commonly used as surrogate primary keys.
Question 5: What is the purpose of a DATABASE LINK in Oracle SQL?
- Creates a hyperlink in SQL reports
- Allows queries to access objects in a remote Oracle database (Correct answer)
- Links a table to a view
- Stores frequently used queries
Correct answer: Allows queries to access objects in a remote Oracle database
A database link (DBLINK) enables Oracle to connect to and query objects in another Oracle database as if they were local.
Question 6: Which Oracle SQL statement removes a view from the database?
- DELETE VIEW
- REMOVE VIEW
- DROP VIEW (Correct answer)
- TRUNCATE VIEW
Correct answer: DROP VIEW
DROP VIEW removes the view definition from the data dictionary; the underlying base tables are not affected.
Which Oracle SQL constraint ensures no two rows in a table have the same value in a column?