开发者

How can I insert a new column after x on a table?

I have a table called users:

CREATE TABLE `users` (
  `UID` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `username` VARCHAR(45) NOT NULL ,
  `password` VARCHAR(200) NOT NULL ,
  `name` VARCHAR(45) NOT NULL ,
  `email` VARCHAR(255) NOT NULL ,
  `phone` VARCHAR(30) NOT NULL ,
  `logo` VARCHAR(255) NULL ,
  `address` VARCHAR(100) NULL ,
  `information` TEXT NULL ,
  `announcement` TEXT NULL ,
  `role` INT UNSIGNED NULL ,
  `yahoo` VARCHAR(100) NULL ,
  `twitter` VARCHAR(20) NULL ,
  `timelogin` DATETIME NULL,
  PRIMARY KEY (`UID`) ,
  UNIQUE INDEX `UID_UNIQUE` (`UID` 开发者_如何学JAVAASC) ,
  UNIQUE INDEX `name_UNIQUE` (`name` ASC) ,
  UNIQUE INDEX `logo_UNIQUE` (`logo` ASC) , 
  UNIQUE INDEX `username_UNIQUE` (`username` ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8

COLLATE = utf8_unicode_ci;

the problem is that I want to add or insert a new row like

`image_seal` VARCHAR(255) NULL ,

after logo, can we do something like that in mysql ? append-thing?

Thanks

Adam Ramadhan


ALTER TABLE users ADD COLUMN image_seal VARCHAR(255) NULL AFTER logo;

Check here for Syntax of ALTER TABLE


It seems you want to add a new column to your table, not a row. From the MySQL reference it seems you can use the keyword AFTER.

ALTER TABLE users ADD COLUMN image_seal VARCHAR(255) AFTER logo;  

should do the trick.


What are you using to administer your database? SQLBuddy, PHPmyAdmin and others can do this for you, without you needing to run queries.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜