Delete, Drop and Truncate Questions for Interview

DROP DATABASE myDB; will

a) Delete all the records from the tables.
b) Delete all the tables from the database.
c) Delete the whole database and its structure.
d) all of the above.

Answer: d

DROP DATABASE will delete the database and everything inside it, including the tables, attributes, index etc.

The DELETE statement will

a) Delete the existing records from the specified table.
b) Delete the whole structure of the table with all its attributes, indexes.
c) Delete the whole database.
d) Delete the existing records from the specified table along with their linked records from another table.

Answer: a

The Delete statement will only delete the existing records from the table. If the WHERE clause is omitted, it will delete all the records from the table. The table and its structure will remain as it is.

TRUNCATE TABLE is used to

a) Delete the table.
b) Delete the data inside a table but not a table itself.
c) Both (a) and (b).
d) None of the above.

Answer: b

TRUNCATE works the same as the DELETE statement without the WHERE clause, where it will delete all the records from the table but not the table itself.

This command is used to remove specific rows from a table 'CUSTOMER' is:

a) REMOVE FROM CUSTOMER
b) DELETE FROM CUSTOMER
c) DELETE FROM CUSTOMER WHERE
d) ALTER FROM CUSTOMER

Answer: c

The DELETE statement will delete the specified rows mentioned in the WHERE clause, whereas the DELETE statement without the WHERE clause will delete all the rows from the table.

Which statement should you execute when you do not want to rollback your data?

a) Delete
b) Truncate

CORRECT ANSWER : b) Truncate

TRUNCATE statement removes all rows from a table or specified partitions of a table, without logging the individual row deletions. TRUNCATE statement is similar to the DELETE statement with no WHERE clause; however, TRUNCATE statement is faster and uses fewer system and transaction log resources. TRUNCATE statement executes when you do not want to rollback your data.
Post your comment