Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Alter Table in MySql

In this tutorial we will see the commands which we can use to make changes in our table (as per April 2k21).

  • To add a column in an existing table:
Syntax: ALTER TABLE table_name ADD column_name DATATYPE;
  • To delete a column in an existing table:
Syntax: ALTER TABLE table_name DROP column_name;
  • To change the data type of a column in an existing table:
Syntax: ALTER TABLE table_name MODIFY COLUMN column_name NEW DATA TYPE;
  • To rename a column in an existing table:
Syntax: ALTER TABLE table_name CHANGE column_name NEW_COLUMN_NAME;
  • To update the column as NOT NULL Constraint:
Syntax: ALTER TABLE table_name MODIFY column_name DATATYPE NOT NULL;
  • To Sort the data in the Table:
Syntax: SELECT "column_name" FROM "table-name" [WHERE "condition"] ORDER BY "column_name" [ASC/DESC];

Joydeep M
Latest posts by Joydeep M (see all)
Tagged : / / / / /
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x