The document might be confusing. I have just figured the syntax for <index_key_definiton> was not completely correct, fixed now.
Ok, the
index_name shouldn't be specified for PRIMARY KEYs. It is only allowed (optional) for the other type of indexes (KEY or UNIQUE).
As per the document, the syntax for a
PRIMARY KEY is as follows:
Code: Select all
PRIMARY KEY (<index_key_definition>[,...])
That is the string
PRIMARY KEY followed by a comma separated list of <index_key_definition> elements, enclosed between parentheses.
The syntax for
<index_key_definition> is:
Where
column_name is a SQL identifier that can be optionally followed by a length specifier (depending on the data type of the column), a white space and an order specifier (
ASC, which is the default or
DESC).
A PRIMARY KEY is like a unique index with the NOT NULL attribute, but it also defines a constraint that can be referenced from other tables. Some SQL engines (that support referencial integrity) allow to define the name of this constraint, but that uses another syntax similar to:
Code: Select all
CONSTRAINT name PRIMARY KEY(foo, bar)
This syntax may vary between SQL engines and we do not use referencial integrity defintions (it is probably very complex to translate between SQL engines) in phpBB databases, so we simply support the tipical way of doing this in MySQL (as described above) and the parser will transform the statement as appropriate. When a constraint name is needed by the parser (thing that could also happen with index names, because it is optional to specify them) the parser generates an identifier derived from the table name.
Maybe you already know some of these things, but I hope it helps to clarify the question.
