ALTER TABLE users ADD COLUMN mobile VARCHAR(20) UNIQUE;
ALTER TABLE users ADD COLUMN mobile VARCHAR(20) AFTER email UNIQUE;
ALTER TABLE users ADD COLUMN mobile VARCHAR(20) BEFORE email UNIQUE;
2. Add multiple columns example:
ALTER TABLE users
ADD COLUMN `count` SMALLINT(6) NOT NULL AFTER `lastname`,
ADD COLUMN `log` VARCHAR(12) NOT NULL AFTER `count`,
ADD COLUMN `status` INT(10) UNSIGNED NOT NULL AFTER `log`;
3. Edit column (name, type, attribute) example:
ALTER TABLE users CHANGE mobile mobile_no VARCHAR(15) UNIQUE;
Comments 0