186k views
2 votes
You manage a database with a table customers. You created a temporary table also called customers with which you are working for the duration of your session. You need to recreate the temporary table with different specs. Which command do you need to run first?

a) ALTER TABLE customers RENAME TO temp_customers;
b) DROP TABLE temp_customers;
c) CREATE TEMPORARY TABLE temp_customers;
d) RENAME TABLE temp_customers TO customers;

User TriV
by
7.7k points

1 Answer

7 votes

Final answer:

The command you need to run first to recreate the temporary table with different specs is DROP TABLE temp_customers.

Step-by-step explanation:

The command you need to run first to recreate the temporary table with different specs is b) DROP TABLE temp_customers;

When you drop the temporary table, it gets removed from the database, allowing you to create a new one with different specifications. The other options do not achieve the same result. Option a) ALTER TABLE customers RENAME TO temp_customers; renames the original customers table, not the temporary table. Option c) CREATE TEMPORARY TABLE temp_customers; creates a new temporary table without removing the old one. Option d) RENAME TABLE temp_customers TO customers; renames the temporary table back to the original name.

User Sawyer Merchant
by
8.3k points