3 Questions
What is the correct SQL statement to rename a table in a database?
RENAME TABLE old_table TO new_table;
How do you add a new column to an existing table in SQL?
ALTER TABLE table_name ADD column_name datatype;
What is the correct SQL statement to modify the datatype of a column in a table?
ALTER TABLE table_name MODIFY COLUMN column_name datatype;
Study Notes
Renaming a Table
- The correct SQL statement to rename a table is:
ALTER TABLE old_table_name RENAME TO new_table_name;
Adding a New Column
- To add a new column to an existing table, use the
ALTER TABLE
statement with theADD COLUMN
clause:ALTER TABLE table_name ADD COLUMN new_column_name data_type;
Modifying a Column's Data Type
- To modify the data type of a column, use the
ALTER TABLE
statement with theMODIFY
orALTER COLUMN
clause:ALTER TABLE table_name MODIFY column_name new_data_type;
orALTER TABLE table_name ALTER COLUMN column_name TYPE new_data_type;
Test your SQL knowledge with this quiz on renaming, adding, and modifying tables and columns. Put your skills to the test with questions on RENAME TABLE, ALTER TABLE - ADD Column, ALTER TABLE - RENAME COLUMN, and ALTER TABLE - ALTER/MODIFY DATATYPE statements.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free