Search code examples
textsqliteprimary-keynvarchar

Random nvarchar(255) id as primary key in SQLite


I am creating a SQLite database which uses an id field as the primary key. Is it possible to create an automatic id which is equivalent to a random nvarchar(255) string?

I need it this way because later on I replace this pre-existing database with one being populated by a web service and the default value for id is (CONVERT(nvarchar,newid(),(0))).

I am using the SQLite3 shell for Windows.


Solution

  • In SQLite, an automatically generated ID must be a 64-bit integer.

    Values of any other data type must be generated manually.