Oracle Database Sql Certified Associate · Free Practice Question Medium
Question 15
View and examine the following SQL exhibit.
The following command has been executed.
Exhibit: 1
- DROP TABLE employees:
Identify the true statements. (Choose three)
-
A
The EMPLOYEES table can be recovered using the ROLLBACK command.
-
B
The EMPLOYEES table may be moved to the recycle bin.
-
C
If there is an uncommitted transaction in the session, it is committed.
-
D
All indexes and constraints defined on the table being dropped are also dropped.
-
E
Sequences used in the EMPLOYEES table become invalid.
-
F
The space used by the EMPLOYEES table is always reclaimed immediately.
Reveal correct answers
Correct answers: B, C, D
Explanation
Correct Statements:
All indexes and constraints defined on the table being dropped are also dropped.
When a table is dropped, all dependent objects like indexes, constraints, triggers, and privileges are also dropped automatically.
The EMPLOYEES table may be moved to the recycle bin.
If the recycle bin is enabled (which it is by default in most Oracle setups), then the table is not immediately removed but renamed and stored in the recycle bin. You can recover it using
FLASHBACK TABLE.
If there is an uncommitted transaction in the session, it is committed.
In Oracle, a
DROP TABLEis a DDL statement, and all DDLs perform an implicit commit before and after the operation. Any uncommitted transactions are automatically committed.
Incorrect Statements:
Sequences used in the EMPLOYEES table become invalid.
Sequences are independent objects and are not tied to the table. Dropping a table does not affect the sequences used by it.
The space used by the EMPLOYEES table is always reclaimed immediately.
If the table goes to the recycle bin, the space is not immediately reclaimed. It is only reclaimed when the table is purged from the recycle bin.
The EMPLOYEES table can be recovered using the ROLLBACK command.
DDL operations cannot be rolled back.
ROLLBACKonly works for DML (likeINSERT,UPDATE,DELETE) — not forDROP.
Use the DROP TABLE statement to move a table or object table to the recycle bin or to remove the table and all its data from the database entirely.
Unless you specify the PURGE clause, the DROP TABLE statement does not result in space being released back to the tablespace for use by other objects, and the space continues to count toward the user's space quota.
For an external table, this statement removes only the table metadata in the database. It has no affect on the actual data, which resides outside of the database.
When you drop a table that is part of a cluster, the table is moved to the recycle bin. However, if you subsequently drop the cluster, the table is purged from the recycle bin and can no longer be recovered with a FLASHBACK TABLE operation.
Dropping a table invalidates dependent objects and removes object privileges on the table. All indexes and constraints defined on the table being dropped are also dropped.
If you want to re-create the table, then you must regrant object privileges on the table, re-create the indexes, integrity constraints, and triggers for the table, and respecify its storage parameters. Truncating has none of these effects. Therefore, removing rows with the TRUNCATE statement can be more efficient than dropping and re-creating a table.
Statements That Cause an Implicit Commit
The statements listed in this section (and any synonyms for them) implicitly end any transaction active in the current session, as if you had done a COMMIT before executing the statement. If there is an uncommitted transaction in the session, it is committed upon execution of DROP TABLE.
These statements also cause an implicit commit after executing. The intent is to handle each such statement in its own special transaction because it cannot be rolled back anyway.
Data definition language (DDL) statements that define or modify database objects.
ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME, ALTER EVENT, ALTER PROCEDURE, ALTER SERVER, ALTER TABLE, ALTER VIEW, CREATE DATABASE, CREATE EVENT, CREATE INDEX, CREATE PROCEDURE, CREATE SERVER, CREATE TABLE, CREATE TRIGGER, CREATE VIEW, DROP DATABASE, DROP EVENT, DROP INDEX, DROP PROCEDURE, DROP SERVER, DROP TABLE, DROP TRIGGER, DROP VIEW, RENAME TABLE, TRUNCATE TABLE.
ALTER FUNCTION, CREATE FUNCTION and DROP FUNCTION also cause an implicit commit when used with stored functions, but not with user-defined functions.
A. The EMPLOYEES table cannot be recovered using the ROLLBACK command once it has been dropped. The ROLLBACK command is used to undo changes made within a transaction, not to recover dropped objects.
B. The EMPLOYEES table may be moved to the recycle bin when dropped. The recycle bin is a feature in Oracle Database that stores dropped objects temporarily, allowing them to be recovered if needed.
C. If there is an uncommitted transaction in the session, it will be committed when the table is dropped. Dropping a table is a DDL operation that automatically commits any pending transactions.
D. All indexes and constraints defined on the table being dropped are also dropped. When a table is dropped, all associated indexes and constraints are also removed from the database.
E. Sequences used in the EMPLOYEES table do not become invalid when the table is dropped. Sequences are separate database objects and are not affected by the dropping of a table.
F. The space used by the EMPLOYEES table is not always immediately reclaimed when the table is dropped. The space may be marked as available for reuse, but it is not immediately released back to the operating system.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
