Bug #8404 unique not documented in column definition
Submitted: 9 Feb 2005 21:40 Modified: 10 Feb 2005 18:51
Reporter: Bill Karwin (Candidate Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:4.1 OS:Any (all)
Assigned to: Paul DuBois CPU Architecture:Any

[9 Feb 2005 21:40] Bill Karwin
Description:
The following statements are correct, but not covered by the reference documentation for CREATE TABLE:

create table t1 (c1 int unique)
create table t2 (c1 int unique key)
create table t3 (c1 int unique key primary key)
create table t4 (c1 int unique key key)

How to repeat:
Enter sample create table statements in mysql tool to observe that they execute without error, and produce schema with expected semantics.

Compare to existing reference documentation for create table statement.  The syntax is not covered in the rule for COLUMN_DEFINITION.

Suggested fix:
On the documentation page for CREATE TABLE, change the following rule:

COLUMN_DEFINITION:
         COL_NAME TYPE [NOT NULL | NULL] [DEFAULT DEFAULT_VALUE]
             [AUTO_INCREMENT] [[PRIMARY] KEY] [COMMENT 'STRING']
             [REFERENCE_DEFINITION]

to this:

COLUMN_DEFINITION:
         COL_NAME TYPE [NOT NULL | NULL] [DEFAULT DEFAULT_VALUE]
             [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY] 
             [COMMENT 'STRING'] [REFERENCE_DEFINITION]

Even though one can specify both a unique key and a primary key, this would be redundant because the latter overshadows the former.  I suggest clarifying the recommended usage by describing the two clauses as either-or, despite what the grammar supports.
[10 Feb 2005 18:51] Paul DuBois
Thank you for your bug report. This issue has been addressed in the
documentation. The updated documentation will appear on our website
shortly, and will be included in the next release of the relevant
product(s).

Additional info:

Thanks for the report.