Ben Lewis Ben Lewis - 1 year ago 142
Android Question

Do you need both primary key AND autoincrement for creating table in SQLite?

Or can you just use one or the other? I'd like to avoid redundancy while ensuring uniqueness by just using PRIMARY KEY but am wondering whether the added rows will AUTOINCREMENT by default.

Answer Source

Yes, added rows will have automatically generated values for primary keys if you don't supply an explicit non-null value yourself. The algorithm for generating such values is slightly different with and without AUTOINCREMENT keyword.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download