Sometimes we need to drop a column that we don't need further from the table. We can do this by using DROP keyword with ALTER command.
Syntax:
To drop/delete the column from a table, use the following syntax:
ALTER TABLE table_name
DROP COLUMN column_name;
Example: Suppose we have a table user as below:
user
id user_name country age
.......................................
1 John Canada 21
2 Chris America 25
3 Joy London 28
4 Jenny Korea
Now we want to delete the column named "age" in the "user" table. For that we use the below statement
ALTER TABLE user
DROP COLUMN age;
Result: The "user" table will now look like as below:
id user_name country
.............................
1 John Canada
2 Chris America
3 Joy London
4 Jenny Korea
Hope this will help you :)
0 Comment(s)