Today we will learn
how to alter table in MySqlWorkbench
ALTER
TABLE STATEMENT
The ALTER TABLE
statement is used to add, delete, or modify columns in an existing table.
SQL
ALTER TABLE Syntax
To delete a column in a table, use the following syntax (notice that some database systems don't allow deleting a column):
ALTER TABLE table_name
DROP COLUMN column_name
Here in example, we
delete the "empsal" column with the following statement:
Then execute it by clicking on second button. then it green tick mark available.
We have to refresh it. Then it affects to the table we can see as in the columns list of the table.
ALTER TABLE table_name
ADD column_name datatype
In my example, we are
going to modify the table "emp" we are going to add a new column
"salary"
Alter table
emp add column designation varchar(40);
Then Press on execute button
Then if execution with no syntax
errors, green tick marks appears.
Then added column
name in the column list of the table.
Related Topics:
No comments:
Post a Comment