开发者

MySQL Alter Table Add Field Before or After a field already present

开发者 https://www.devze.com 2023-01-09 12:33 出处:网络
I have this, but it doesn\'t work: $query = \"ALTER TABLE `\".$table_prefix.\"posts_to_bookmark` ADD `ping_status` INT( 1 ) NOT NULL BEFORE `开发者_JS百科onlywire_status`\";

I have this, but it doesn't work:

$query = "ALTER TABLE `".$table_prefix."posts_to_bookmark` 
            ADD `ping_status` INT( 1 ) NOT NULL BEFORE `开发者_JS百科onlywire_status`";

I appreciate it!


$query = "ALTER TABLE `" . $table_prefix . "posts_to_bookmark` 
          ADD COLUMN `ping_status` INT(1) NOT NULL 
          AFTER `<TABLE COLUMN BEFORE THIS COLUMN>`";

I believe you need to have ADD COLUMN and use AFTER, not BEFORE.

In case you want to place column at the beginning of a table, use the FIRST statement:

$query = "ALTER TABLE `" . $table_prefix . "posts_to_bookmark`
          ADD COLUMN `ping_status` INT(1) NOT NULL 
          FIRST";

http://dev.mysql.com/doc/refman/5.1/en/alter-table.html

0

精彩评论

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