mardi 13 octobre 2015

How to insert a unique random integer in SQLite?

Let's say I'm saving users in a database and I want each user to have a unique random ID (this isn't actually the case, just a simpler example). When I INSERT the user, is there a way to insert a unique random ID?

I know I can easily just do an auto-increment column so that each row would have a unique integer, but I need a random number for this system specifically.

Sample of what my standard insert query for a new user:

INSERT INTO 'Users' VALUES ('RandomID', 'Bleh', 'Bleh2') (random value here, 1, 2)

Aucun commentaire:

Enregistrer un commentaire