A

Admin • 802.91K Points
Coach

Q. Which statement creates a copy of an existing table structure without copying data?

  • (A) CREATE TABLE new_table AS SELECT * FROM old_table WHERE 1=0
  • (B) CREATE TABLE new_table LIKE old_table
  • (C) INSERT INTO new_table SELECT * FROM old_table LIMIT 0
  • (D) ALTER TABLE old_table RENAME TO new_table
  • Correct Answer - Option(B)
  • Views: 1
  • Filed under category MySQL
  • Hashtags:

Explanation by: Admin
CREATE TABLE ... LIKE copies the table structure including indexes. Option A (CREATE ... AS SELECT ... WHERE 1=0) also creates structure but may not copy indexes or other definition details. INSERT ... LIMIT 0 assumes the new_table exists. RENAME moves the table rather than creating a copy.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.