Consider a database with a table named Employees. What happens if you run the following SQL command?
DROP TABLE Employees;
What will be the state of the Employees table after this command?
Think about what DROP means in SQL.
The DROP TABLE command removes the entire table and all its data permanently from the database.
Given a table Products with columns id and name, what is the effect of this command?
ALTER TABLE Products ADD COLUMN price DECIMAL(10,2);
Look at the keywords ADD COLUMN in the command.
The command adds a new column called price with decimal type to the existing Products table.
You want to rename the column old_name to new_name in the table Customers. Which of the following commands is correct in standard SQL?
Standard SQL uses a specific syntax for renaming columns.
The standard SQL syntax to rename a column is ALTER TABLE table_name RENAME COLUMN old_name TO new_name;. Other options are dialect-specific or invalid.
Consider the command:
DROP TABLE Orders;
It fails with an error saying the table does not exist. What is the best way to avoid this error?
Check if the table exists before dropping it.
The IF EXISTS clause prevents errors if the table does not exist by only dropping it when present.
Table Orders has a foreign key referencing Customers. What happens if you run:
DROP TABLE Customers;
Assuming no special options are used, what is the expected outcome?
Think about referential integrity rules in relational databases.
Most databases prevent dropping a table if other tables have foreign keys referencing it, to avoid broken references.