i want to use alter table
我想使用alter table
but the syntax posted here:
但是这里发布的语法:
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
is very confusing
非常混乱
i do not understand what the [ ]
mean or the { }
mean or the pipes
我不明白[]是什么意思或{}意思或管道
is there some kind of tutorial that can help me understand this?
是否有某种教程可以帮助我理解这一点?
4 个解决方案
#1
12
- The brackets
[ ]
denote optional expressions - The pipes mean OR.
- The braces
{ }
group words for the pipes.
方括号[]表示可选表达式
管道意味着OR。
大括号{}组合管道的单词。
For example:
-
[COLUMN]
means that the wordCOLUMN
can optionally appear -
{INDEX|KEY}
means that eitherINDEX
orKEY
must appear -
[FIRST | AFTER col_name ]
means that the wordFIRST
orAFTER (the name of a column)
can optionally appear
[COLUMN]表示可以选择显示单词COLUMN
{INDEX | KEY}表示必须出现INDEX或KEY
[FIRST | AFTER col_name]表示可以选择显示单词FIRST或AFTER(列名)
#2
6
[]
means, that argument inside is optional{a|b}
means that you have to choose whether a
or b
[]表示,里面的参数是可选的{a | b}意味着你必须选择a或b
UPD: specifically for mysql you should look over here: http://dev.mysql.com/doc/refman/5.1/en/manual-conventions.html
UPD:专门针对mysql你应该看看这里:http://dev.mysql.com/doc/refman/5.1/en/manual-conventions.html
#3
4
Example of an alter table statement to add a column to a table:
用于向表中添加列的alter table语句的示例:
ALTER TABLE tablename ADD COLUMN columnname INT
changing a column's name:
更改列名称:
ALTER TABLE tablename CHANGE COLUMN columnname newname INT
rename table:
ALTER TABLE tablename RENAME newname
drop a field from a table
从表中删除一个字段
ALTER TABLE tablename DROP columname
On the syntax side, the user @SLaks has a good answer.
在语法方面,用户@SLaks有一个很好的答案。
#4
2
Oh well. It's the full reference and I think for starting it's really an overkill. Maybe you should try more simple and informal guides on the topic, like http://www.w3schools.com/sql/sql_alter.asp or http://infogoal.com/sql/sql-alter-table.htm etc. etc. If you get a book covering basic SQL stuff I'm quite sure that you'll find a nice explanation, too. If you understand the basics, you can go with the more complicated stuff in the reference (if you need it).
好吧。这是完整的参考,我认为开始它真的是一种矫枉过正。也许您应该尝试更多关于该主题的简单和非正式指南,如http://www.w3schools.com/sql/sql_alter.asp或http://infogoal.com/sql/sql-alter-table.htm等。如果你得到一本涵盖基本SQL内容的书,我很确定你也能找到一个很好的解释。如果您了解基础知识,则可以使用参考中更复杂的内容(如果需要)。
#1
12
- The brackets
[ ]
denote optional expressions - The pipes mean OR.
- The braces
{ }
group words for the pipes.
方括号[]表示可选表达式
管道意味着OR。
大括号{}组合管道的单词。
For example:
-
[COLUMN]
means that the wordCOLUMN
can optionally appear -
{INDEX|KEY}
means that eitherINDEX
orKEY
must appear -
[FIRST | AFTER col_name ]
means that the wordFIRST
orAFTER (the name of a column)
can optionally appear
[COLUMN]表示可以选择显示单词COLUMN
{INDEX | KEY}表示必须出现INDEX或KEY
[FIRST | AFTER col_name]表示可以选择显示单词FIRST或AFTER(列名)
#2
6
[]
means, that argument inside is optional{a|b}
means that you have to choose whether a
or b
[]表示,里面的参数是可选的{a | b}意味着你必须选择a或b
UPD: specifically for mysql you should look over here: http://dev.mysql.com/doc/refman/5.1/en/manual-conventions.html
UPD:专门针对mysql你应该看看这里:http://dev.mysql.com/doc/refman/5.1/en/manual-conventions.html
#3
4
Example of an alter table statement to add a column to a table:
用于向表中添加列的alter table语句的示例:
ALTER TABLE tablename ADD COLUMN columnname INT
changing a column's name:
更改列名称:
ALTER TABLE tablename CHANGE COLUMN columnname newname INT
rename table:
ALTER TABLE tablename RENAME newname
drop a field from a table
从表中删除一个字段
ALTER TABLE tablename DROP columname
On the syntax side, the user @SLaks has a good answer.
在语法方面,用户@SLaks有一个很好的答案。
#4
2
Oh well. It's the full reference and I think for starting it's really an overkill. Maybe you should try more simple and informal guides on the topic, like http://www.w3schools.com/sql/sql_alter.asp or http://infogoal.com/sql/sql-alter-table.htm etc. etc. If you get a book covering basic SQL stuff I'm quite sure that you'll find a nice explanation, too. If you understand the basics, you can go with the more complicated stuff in the reference (if you need it).
好吧。这是完整的参考,我认为开始它真的是一种矫枉过正。也许您应该尝试更多关于该主题的简单和非正式指南,如http://www.w3schools.com/sql/sql_alter.asp或http://infogoal.com/sql/sql-alter-table.htm等。如果你得到一本涵盖基本SQL内容的书,我很确定你也能找到一个很好的解释。如果您了解基础知识,则可以使用参考中更复杂的内容(如果需要)。