Which of the following SQL statements is correct?

  1. TRUNCATE Sales TABLE

  2. TRUNCATE * FROM TABLE Sales

  3. TRUNCATE TABLE Sales

  4. TRUNCATE * FROM COLUMN Sales


Correct Option: C

AI Explanation

To answer this question, you need to understand the correct syntax for the TRUNCATE statement in SQL. Let's go through each option to understand why it is correct or incorrect:

A) TRUNCATE Sales TABLE - This option is incorrect because the correct syntax for the TRUNCATE statement does not include the keyword "TABLE" after the table name. The correct syntax is "TRUNCATE TABLE Sales."

B) TRUNCATE * FROM TABLE Sales - This option is incorrect because the TRUNCATE statement does not use the "FROM" keyword or the asterisk (*) to specify columns or rows to be truncated. The correct syntax is "TRUNCATE TABLE Sales."

C) TRUNCATE TABLE Sales - This option is correct because it follows the correct syntax for the TRUNCATE statement in SQL. The "TRUNCATE TABLE" syntax is used to delete all rows from a table without logging individual row deletions. The "Sales" in this statement is the name of the table to be truncated.

D) TRUNCATE * FROM COLUMN Sales - This option is incorrect because the TRUNCATE statement does not use the "FROM" keyword or the "COLUMN" keyword. The correct syntax is "TRUNCATE TABLE Sales."

The correct answer is C. This option is correct because it follows the correct syntax for the TRUNCATE statement in SQL, which is "TRUNCATE TABLE [table_name]". In this case, the table name is "Sales."

Find more quizzes: