SQL RENAME TABLE syntax is used to change the name of a table. Sometimes, we choose non-meaningful name for the table. So it is required to be changed. Let's see the syntax to rename a table from the database.
Let us take an example of a table named "STUDENTS" to "ARTISTS"
ALTER TABLE STUDENTS RENAME TO ARTISTS;
Optionally, you can write following command to rename the table.
RENAME old_table _name To new_table_name;
The ALTER TABLE statement is used to add, modify or delete columns in an existing table. It is also used to rename a table. You can also use SQL ALTER TABLE command to add and drop various constraints on an existing table.
If you want to add columns in SQL table, the SQL alter table syntax is given below:
ALTER TABLE table_name ADD column_name column-definition;
If you want to add multiple columns in table, the SQL table will be
ALTER TABLE table_name ADD (column_1 column-definition, column_2 column-definition, ..... column_n column-definition);
If you want to modify an existing column in SQL table, syntax is given below:
ALTER TABLE table_name MODIFY column_name column_type;
If you want to modify multiple columns in table, the SQL table will be
ALTER TABLE table_name
MODIFY (column_1 column_type,
The syntax of alter table drop column is given below:
ALTER TABLE table_name DROP COLUMN column_name;
The syntax of alter table rename column is given below:
ALTER TABLE table_name RENAME COLUMN old_name to new_name;← Previous Next →
© 2018 BreakInerview