MySQL 将一列插入到 phpmyadmin 中预先存在的表中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18064495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Inserting a Column to preexisting table in phpmyadmin
提问by StrawhatLuffy
I want to add a column to preexisting table. Can I add it in between two existing columns? I am working on phpmyadmin.
我想向预先存在的表中添加一列。我可以将它添加到两个现有列之间吗?我在 phpmyadmin 上工作。
回答by danmc
Use the add new column after dropdown.
使用下拉列表后添加新列。
Select the database from the menu on the left.
Select the table by clicking on it's title column hyperlink.
Check the add new column after radio button and select the column you want to insert after in the drop down.
Click Add.
从左侧菜单中选择数据库。
通过单击其标题列超链接来选择表格。
选中在单选按钮之后添加新列,然后在下拉列表中选择要插入的列。
单击添加。
This video goes through the process http://www.youtube.com/watch?v=jZ72GCGWPQg
回答by Vaughan Hilts
You want something like:
你想要这样的东西:
ALTER TABLE contacts ADD email VARCHAR(60);
回答by hjpotter92
The ordering of columns in MySQLisn't of much importance. As for adding a new column,
ALTER TABLE `tblName`
ADD COLUMN `colName` INT(10) AFTER `firstCol`;
The AFTER
clause defines the position where your new column will come.
该AFTER
子句定义了新列将出现的位置。
回答by Maxime Lorant
I think this videocan help you. With PHPMyAdmin
我认为这个视频可以帮助你。使用 PHPMyAdmin
- Go to the page of the table you want to modify
- At the bottom of the page, select you desired column in "After" (at which position you want to add your column in the table)
- Validate and enter new column information
- 转到您要修改的表的页面
- 在页面底部,在“之后”中选择您想要的列(您要在表格中添加您的列的位置)
- 验证并输入新的列信息
You can also do it via plain SQL, with a ALTER TABLE
query:
您也可以通过普通 SQL 使用ALTER TABLE
查询来完成:
ALTER TABLE mytable ADD column3 INT AFTER column1
回答by Shemeer M Ali
Yes, you can do that. See a "after" list box in the section. you can select after which field your new field need to be added.
是的,你可以这样做。请参阅部分中的“之后”列表框。您可以选择需要添加新字段的字段。