Learning to understand syntax syntax

I want to use alter table

but the syntax posted here:

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

very confusing

I don’t understand what the meaning of [ ] or { } , or pipes

is there some kind of tutorial that can help me figure this out?

+7
syntax sql mysql
source share
4 answers
  • Brackets [ ] indicate optional expressions
  • Proceedings mean OR.
  • Brackets { } group words for pipes.

For example:

  • [COLUMN] means the word COLUMN possible
  • {INDEX|KEY} means either INDEX or KEY should appear
  • [FIRST | AFTER col_name ] [FIRST | AFTER col_name ] means that the word FIRST or AFTER (the name of a column) may optionally be displayed
+12
source share

[] means that the argument inside is optional
{a|b} means you need to choose whether a or b

UPD : specifically for mysql you should look here: http://dev.mysql.com/doc/refman/5.1/en/manual-conventions.html

+6
source share

An example alter table statement to add a column to a table:

 ALTER TABLE tablename ADD COLUMN columnname INT 

column name change:

 ALTER TABLE tablename CHANGE COLUMN columnname newname INT 

rename table:

 ALTER TABLE tablename RENAME newname 

remove field from table

 ALTER TABLE tablename DROP columname 

On the syntax side, @SLaks user has a good answer.

+4
source share

Good. This is a complete reference, and I think this is really overkill for starters. Perhaps you should try simpler and more informal guides on this topic, for example http://www.w3schools.com/sql/sql_alter.asp or http://infogoal.com/sql/sql-alter-table.htm , etc. .d. etc. If you get a book that talks about basic SQL materials, I'm pretty sure you will find a good explanation, too. If you understand the basics, you can go with more complex material in the link (if you need it).

+2
source share

All Articles