Alter table add column | MODIFY COLUMN SYNTAX IN SQL - sql - sql tutorial - learn sql




Alter Table Alter Column.jpg
  • The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
  • The ALTER TABLE statement is also used to add and drop various constraints on an existing table.
  • The SQL Server (Transact-SQL) ALTER TABLE can use the ALTER TABLE statement in SQL Server to add a column to a table.
    • Add multiple columns in table.
    • Modify column in table.
    • Drop column in table.
    • Rename column in table and etc.
Alter Table Alter Column
  • For Oracle and MySQL, the SQL syntax for ALTER TABLE Modify Column is,
ALTER TABLE "table_name"
MODIFY "column_name" "New Data Type";
  • For SQL Server, the syntax is,
ALTER TABLE "table_name"
ALTER COLUMN "column_name" "New Data Type";
  • Let's look at the example. Assuming our starting point is the Customer table created in the CREATE TABLE section:

Table Wikitechy_Customer

Column Name Data Type
First_Name char(50)
Last_Name char(50)
Address char(50)
City char(50)
Country char(25)
Birth_Date datetime
  • Our goal is to alter the data type of the "Address" column to char(100). To do this, we key in:

MySQL:

ALTER TABLE Wikitechy_Customer MODIFY Address char(100);
Tags : sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorial

Oracle:

ALTER TABLE Wikitechy_Customer MODIFY Address char(100);
Tags : sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorial

SQL Server:

ALTER TABLE Wikitechy_Customer ALTER COLUMN Address char(100);
sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorial

Resulting table structure:

Table Wikitechy_Customer

Column Name Data Type
First_Name char(50)
Last_Name char(50)
Address char(100)
City char(50)
Country char(25)
Birth_Date datetime

This tutorial provides more the basic needs and informations on sql tutorial , pl sql tutorial , mysql tutorial , sql server , sqlcode , sql queries , sql , sql formatter , sql join , w3schools sql , oracle tutorial , mysql , pl sql , learn sql , sql tutorial for beginners , sql server tutorial , sql query tutorial , oracle sql tutorial , t sql tutorial , ms sql tutorial , database tutorial , sql tutorial point , oracle pl sql tutorial , oracle database tutorial , oracle tutorial for beginners , ms sql server tutorial , sql tutorial pdf

Related Searches to Alter table add column

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×