SQL – ALTER TABLE

Prev     Next

SQL – ALTER TABLE statement can be used to rename a table as well as to add, modify and delete columns of the table.

Syntax for various ALTER TABLE Statement is given below:

1. To add a column:

Syntax:

ALTER TABLE table_name ADD column_name data_type;

Example:

ALTER TABLE student ADD Address VARCHAR(255);

2. To modify a column:

Syntax:

ALTER TABLE table_name MODIFY column_name column_type;

Example:

ALTER TABLE student MODIFY  Student_ID int NOT NULL;

3. To drop or delete a column:

Syntax:

ALTER TABLE table_name DROP COLUMN column_name;

Example:

ALTER TABLE student  DROP COLUMN City;

4. To rename a column:

Syntax:

ALTER TABLE table_name  RENAME COLUMN old_name to new_name;

Example:

ALTER TABLE student  RENAME COLUMN Address to FULL_ADDRESS;

5. To rename a table:

Syntax:

RENAME TABLE existing_table_name TO new_table_name

Example:

RENAME TABLE student TO student_A

Prev     Next

Ask your questions or clarify your/others doubts from,

✅ Online Discussion Forums by Fresh2Refresh.com





Share this website !!!
Facebook Twitter Linkedin

Close
We Support JALLIKATTU !!!
We Support JALLIKATTU!
By Fresh2Refresh.com
Show Your Support as well. Thanks!