Re: Invalid primary key?
Primary keys cannot be named, so your SQL should instead look like
this:
CREATE TABLE zzz (
zzz mediumint(8) NOT NULL,
PRIMARY KEY (zzz)
);
phpMyAdmin is probably detecting the error and correcting it
automatically.
On Feb 11, 10:04 am, zelnaga <zeln...@gmail.com> wrote:
> I tried to run some SQL through throughhttp://sql.phpmix.comand got
> an error I don't understand.
>
> Here's the SQL:
>
> CREATE TABLE zzz (
> zzz mediumint(8) NOT NULL,
> PRIMARY KEY zzz (zzz)
> );
>
> Here's the error:
>
> Invalid primary key "PRIMARY KEY zzz(zzz)"
>
> According to the source code, "Index name is not allowed for primary
> keys".
>
> If I run the code in phpMyAdmin, it works just fine. The thing I'm
> trying to figure out is... is doing "PRIMARY KEY zzz (zzz)" just
> considered bad practice? Browsers have quirks mode for badly written
> HTML - is "PRIMARY KEY zzz (zzz)" badly written SQL that phpMyAdmin
> and MySQL just interpret using a quirks mode of sorts?
|