LINUX.ORG.RU

История изменений

Исправление theNamelessOne, (текущая версия) :

In most cases, UNIQUE and PRIMARY KEY constraints are implemented by creating a unique index in the database. (The exceptions are INTEGER PRIMARY KEY and PRIMARY KEYs on WITHOUT ROWID tables.) Hence, the following schemas are logically equivalent:

CREATE TABLE t1(a, b UNIQUE);
CREATE TABLE t1(a, b PRIMARY KEY);
CREATE TABLE t1(a, b);
CREATE UNIQUE INDEX t1b ON t1(b);

Исходная версия theNamelessOne, :

В любой непонятной ситуации смотри документацию

In most cases, UNIQUE and PRIMARY KEY constraints are implemented by creating a unique index in the database. (The exceptions are INTEGER PRIMARY KEY and PRIMARY KEYs on WITHOUT ROWID tables.) Hence, the following schemas are logically equivalent:

  1. CREATE TABLE t1(a, b UNIQUE);
  2. CREATE TABLE t1(a, b PRIMARY KEY);
  3. CREATE TABLE t1(a, b);
    CREATE UNIQUE INDEX t1b ON t1(b);