MySQL Alter Table添加字段之前或之后的字段已经存在 [英] MySQL Alter Table Add Field Before or After a field already present
本文介绍了MySQL Alter Table添加字段之前或之后的字段已经存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个,但是不起作用:
I have this, but it doesn't work:
$query = "ALTER TABLE `".$table_prefix."posts_to_bookmark`
ADD `ping_status` INT( 1 ) NOT NULL BEFORE `onlywire_status`";
我很感激!
推荐答案
$query = "ALTER TABLE `" . $table_prefix . "posts_to_bookmark`
ADD COLUMN `ping_status` INT(1) NOT NULL
AFTER `<TABLE COLUMN BEFORE THIS COLUMN>`";
我相信您需要拥有ADD COLUMN
并使用AFTER
,而不是BEFORE
.
I believe you need to have ADD COLUMN
and use AFTER
, not BEFORE
.
如果要在表的开头放置列,请使用FIRST
语句:
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
这篇关于MySQL Alter Table添加字段之前或之后的字段已经存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文