SQL -Structured Query Language - SQL Table - Alter - Modify Column Tutorial
To modify a column in the existing created table, then we can use an ‘ ALTER TABLE ‘ statement.
With modify, we can only modify the property of a column, but not able to rename the column name.
Syntax-
The basic syntax of the ALTER TABLE statement to modify a column in the existing table is given below –
ALTER TABLE table_name MODIFY
colname colname_datatype;
For example-
If we want to modify
Column
- Status as an Integer – int and default 0 to default 1.
In table user_detail
Then use the following syntax-
ALTER TABLE user_detail MODIFY
status int default 1;
This query or statement will modify the username varchar length to 25 and make the default status to 1 in the user_detail table.
In Mysql Workbench-
This query or statement will modify the default status to 1 in the user_detail table.