Coginiti menu Coginiti menu

Add a Column

How to Add a Column in SQL

You can add a new column in SQL to an existing table using the ALTER TABLE statement.
Here’s the basic syntax:

ALTER TABLE table_name ADD column_name datatype;

ALTER TABLE specifies that you want to modify the structure of the “table_name”, and ADD is the modification you want to make. For example, suppose you have a table named “bookshop”, and you want to add a new column called “genre”.

ALTER TABLE bookshop ADD genre VARCHAR(100);

This statement adds a new column called “genre” to the “bookshop” table, with a data type of VARCHAR(100).

Note that the new column will initially be empty for all existing rows. To change it, use the UPDATE statement and set new values. Also, be careful when adding columns to a table containing a large amount of data, as the operation can be time-consuming and cause performance issues.