MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

SQL

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the difference if we truncate a table and if we drop a table?
A
In both cases, the table is deleted.
B
In both cases, the data is deleted.
C
In truncate, the data is deleted and in drop the whole table is deleted.
D
In truncate, the table is deleted while when the table is dropped the data is deleted.
Explanation: 

Detailed explanation-1: -The DELETE command deletes one or more existing records from the table in the database. The DROP Command drops the complete table from the database. The TRUNCATE Command deletes all the rows from the existing table, leaving the row with the column names.

Detailed explanation-2: -In SQL, the DROP command is used to remove the whole database or table indexes, data, and more. Whereas the TRUNCATE command is used to remove all the rows from the table.

Detailed explanation-3: -The DROP TABLE is another DDL (Data Definition Language) operation. But it is not used for simply removing data from a table; it deletes the table structure from the database, along with any data stored in the table.

Detailed explanation-4: -DELETE command is a DML statement so that it can be rolled back. DROP is used to delete the whole table, including its structure. DROP is a DDL command that lost the data permanently, and it cannot be rolled back. TRUNCATE is used to delete the whole records, but it preserves the table’s schema or structure.

There is 1 question to complete.