ALTER TABLE Clause In SQL

Article SQL

THE SQL ALTER TABLE CLAUSE

The SQL ALTER TABLE Clause is used to add, update, or drop/delete columns in a table. The SQL ALTER TABLE Clause is also used to rename a table.

Add a column in the table

Syntax

To add a column in a table, the ALTER TABLE syntax in SQL is,

ALTER TABLE table_name
ADD column_name datatype;

Example

ALTER table solo
ADD Grade Varchar (10);

ALTER TABLE Clause In SQL

With the help of ALTER TABLE Command, the Grade column is added.

ALTER TABLE Clause In SQL

Modify column in the table

Syntax

To modify a column in an existing table, the SQL ALTER TABLE syntax is:

ALTER TABLE table_name
ALTER COLUMN column_name datatype;

Example

ALTER TABLE solo
MODIFY COLUMN Course VARCHAR(10);

ALTER TABLE Clause In SQL

Drop column in the table

Syntax

To drop a column in an existing table, the SQL ALTER TABLE syntax is:

ALTER TABLE table_name
DROP COLUMN column_name;

Example

ALTER TABLE solo
DROP COLUMN Grade;

ALTER TABLE Clause In SQL

With the help of the Drop command, the Grade column is deleted.

ALTER TABLE Clause In SQL

Conclusion

In this article, you will understand how to add, delete, modify columns in an existing table.

Jyoti Mishra
Latest posts by Jyoti Mishra (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *