Primärnyckel automatiskt indexerat?

Permalänk
Medlem

Primärnyckel automatiskt indexerat?

Precis som rubriken säger. Så är frågan om Primärnyckeln i en databastabell automatiskt indexeras. Saken är den att jag kan inte välja den som INDEX så jag antar att det borde vara så.

Jag jobbar med MySQL.

tack tack

Permalänk
Medlem

Ja, primärnyckeln indexeras per automatik.

Visa signatur

The power of GNU compiles you!
"Often statistics are used as a drunken man uses lampposts -- for support rather than illumination."

Permalänk
Medlem

Re: Primärnyckeln automatiskt indexerad?

För att vara exakt:

Citat:

A PRIMARY KEY is a unique index where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares them so implicitly (and silently). A table can have only one PRIMARY KEY. If you do not have a PRIMARY KEY and an application asks for the PRIMARY KEY in your tables, MySQL returns the first UNIQUE index that has no NULL columns as the PRIMARY KEY.

http://dev.mysql.com/doc/refman/5.0/en/create-table.html