add column after another column in mysql

add column after another column in mysql – alter table add column after another column mysql. SQL Query to Add a New Column After an Existing Column in SQL Example

add column after another column in mysql

how to use the MySQL ALTER TABLE statement to add a column, modify a column with syntax and examples.

Let’s make a database member.

CREATE DATABASE member;

Step 2: Create a table
Now make a table member_info.

CREATE TABLE member_info
( member_id INT,
First_Name VARCHAR(25),
Last_Name VARCHAR(25),
Salary INT,
City VARCHAR(20)); 

INSERT INTO member_info
VALUES (1,'ruchita','dave',95858885,'Surat'),
(2,'krishna','bhanderi',5695000,'Gondal'),
(3,'rekha','suialia',4875200,'Ahemdabad'),
(4,'chanki','Panday',3659800,'Rajkot');

Alter table.

ALTER TABLE member_info ADD Gender CHAR(1) CHECK (Gender IN ('M','F'));

SELECT member_Id,First_Name,Last_Name,Gender,Salary,City FROM member_info;

don’t miss : mysql order by two columns

Also Read This 👉   Triangle Pattern Program In PHP

sql add column after another

ALTER TABLE member_info ADD Last_Name VARCHAR(255) AFTER First_Name

insert column after column mysql

ALTER TABLE member_info
ADD COLUMN First_Name VARCHAR(15) AFTER Last_Name;

add column in mysql

ALTER TABLE member_info
ADD Email varchar(255);

add column in mysql

ALTER TABLE member_info ADD name_column INT(255);

mysql add column after another

ALTER TABLE `member_info` ADD `Gender` TINYINT NOT NULL DEFAULT '0' AFTER `City`; 

ALTER TABLE `member_info` ADD `Gender` TINYINT(1) NOT NULL DEFAULT '-1'; 

ALTER TABLE `member_info` ADD `Gender` TINYINT NOT NULL DEFAULT '-1' AFTER `City`; 

ALTER TABLE `member_info` ADD `Gender` TEXT NULL DEFAULT NULL AFTER `Salary`;

ALTER TABLE `member_info` ADD `Last_Name` TEXT NULL DEFAULT NULL AFTER `Salary`;

ALTER TABLE `member_info` ADD `City` TEXT NULL DEFAULT NULL AFTER `Salary`;

I hope you get an idea about add column after another column in mysql.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.