How to add a new column in an existing table in MySQL database?

How to add a new column in an existing table in MySQL database?

Alter, Database, MySQL, Table

71 | 0 | 0

We can use ALTER TABLE statement to add a new column in an existing table.

Syntax:

ALTER TABLE <table_name> ADD <column_name> datatype;

Example:

// create table
CREATE TABLE employees (
    id int,
    first_name varchar(255),
    last_name varchar(255),
    email varchar(255),
    City varchar(255),
    state varchar(255),
    country varchar(255)
);

// Alter table to add zip_code column
ALTER TABLE employees ADD zip_code varchar(10);

 

Comments (0)

🤔

No comments yet, be the first to help

Welcome to CodePits.

CodePits provide a collection of tutorials about many programming languages like PHP, Laravel Framework, Codeigniter Framework, Mysql Database, Bootstrap Front-end Framework, Jquery, Node JS, Ajax Example, APIs, CURL Example, Composer Packages Example, AngularJS, Ionic Framework, etc. 🙌

Other Posts

Categories

Tags

Comment