TRENDING TOPICS

×

SQL ALTER TABLE Statement

The ALTER TABLE statement is used to ADD, MODIFY or DELETE/DROP columns in the existing table; Also used to ADD/DROP various constraints and triggers on an existing table.

ALTER TABLE - ADD

ADD keyword is used to add columns into the existing table in SQL Server.

ALTER TABLE - ADD Column Syntax

The ALTER TABLE statement is used to add multiple columns to a table in SQL Server.

ALTER TABLE table_name
  ADD (column_name1 datatype,
  column_name2 datatype
  .
  .
  column_nameN datatype);

ALTER TABLE - DROP Column Syntax

The ALTER TABLE statement is used to drop a column to a table in SQL Server.

ALTER TABLE table_name
DROP COLUMN column_name;

ALTER TABLE - MODIFY Column Syntax

The ALTER TABLE statement is used to modify a column to a table in SQL Server.

ALTER TABLE table_name
MODIFY COLUMN column_name datatype;

EXAMPLE: ALTER TABLE

The 'STUDENTS' Records Table

ID FULL_NAME BRANCH ADDRESS CITY COUNTRY
001 Kalpana Negi CSE #42 3rd Floor, 4th Building, East Mumbai Mumbai India
002 Nishant Devid Civil #543 Main Road, uturn 6th Building Delhi India

Example - ADD Column

ALTER TABLE STUDENTS
  ADD DOB date;

Result Look Like

ID FULL_NAME BRANCH ADDRESS CITY COUNTRY DOB
001 Kalpana Negi CSE #42 3rd Floor, 4th Building, East Mumbai Mumbai India
002 Nishant Devid Civil #543 Main Road, uturn 6th Building Delhi India

Advertise With Us

We offer sponsored posts and guest posts with do-follow links, back-links, and other advertising services, To advertise email us at "advertise@gdatamart.com"

© 2021 GDATAMART.COM (All Rights Reserved)