SQLite Forum

Why do I have a `SQLITE_AUTOINDEX` index for my primary key? Is the table itself not an index on the PK?
Login
Tripehound is correct about why that index exists, but it is perhaps prudent to add that your request for the column to be UNIQUE prompts the creation of the auto index, which means that your explicit CREATE INDEX after the table is completely superfluous and does nothing other than waste some space - best to remove it.


To be clear, this:
```
CREATE TABLE hash (
  id INTEGER PRIMARY KEY NOT NULL,
  base32 TEXT UNIQUE NOT NULL
);
```
is semantically equivalent to this:
```
CREATE TABLE hash (
  id INTEGER PRIMARY KEY NOT NULL,
  base32 TEXT NOT NULL
);
CREATE UNIQUE INDEX hash_base32 ON hash(base32);
```
The only difference being that in the listed indexes, the second one will show the hash_base32 name in stead of the autoindex name.