Insights Technical Hub How to add and drop columns to or from an SQL table

How to add and drop columns to or from an SQL table

Introduction:

Database tables using the Structured Query Language (SQL) can be modified, by adding or removing table columns.

Requirements:

An SQL development environment.

Procedure:

Once a connection to an SQL server is acquired, a table should be identified within a particular database for modification. To add an extra column as the new first column, you may use:

alter table tableName add columnName columnProperties first;

The keyword first may be excluded, if the column is intended to be included as the last column in the table. If you would like to add the new column after a particular column, you may write:

alter table tableName add columnName columnProperties after columnToFollow;

To remove a column, you may simply write:

alter table tableName drop columnName;

This will remove the column from the table.