SQLite Forum

slow import of CSV files
Login
To add - Normally the most obvious difference is that a UNIQUE Index can contain NULL values (where every NULL is regarded as distinct from every other NULL) whereas a PRIMARY KEY is not allowed to have NULL values in normal SQL.

This is enforced in most all SQL engines, but a peculiar bug in SQLite, now maintained for backward compatibility, has allowed SQLite-specific PK's to contain NULLs. This was possible by virtue of normal SQLite tables having a separate rowid indexer, a fact which informs the two exceptions to this rule:  

SQLite PK's cannot contain NULL values in the cases of:

- the rowid-alias PK declared as  
```
" ... INTEGER PRIMARY KEY"
```
- and tables where the rowid is omitted by being declared as:  
```
"CREATE TABLE t(...) WITHOUT ROWID;".
```