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];
Latest posts by Joydeep M (see all)
- Laravel 5.8 CRUD operation with example - April 22, 2021
- How to Create Multiple Role Based Authentication in Laravel 5.8 - April 16, 2021
- SQL Queries - April 5, 2021