Chrome Extension

Add columns, alter table SQL query

ALTER TABLE 
    table_name 
ADD (
    Column_name1 data_type, 
    Column_name2 data_type (size)
);
We are a bunch of lazy programmers so we developed this chrome extension
search code from your favorite search engine
Install Now

ALTER table SQL query is used for adding new columns, constraints, and indexes to a table which already exists in the database. It is also used for changing the behavior of columns of a table.

For example, if you want to add a new column named 'Address' in the 'Employee' table, you can execute below SQL query for that.

ALTER TABLE Employee ADD COLUMN Address varchar(255)
or
ALTER TABLE Employee ADD(Address varchar(255))

Modifying existing column

Syntax:

ALTER TABLE table_name MODIFY (column_name new_data_type(new_size));

Example:

ALTER TABLE Employee MODIFY (Address varchar(255));

Removing column from table

ALTER query can be used to remove a column from the table using below command

ALTER TABLE table_name DROP COLUMN column_name;

Search Index Data (The code snippet can also be found with below search text)

add column sql
Was this helpful?
0 Comments
Open Code Manager We are hiring