0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
Many dialects of SQL support an AUTO INCREMENT
feature. When inserting records into a table with AUTO INCREMENT
enabled, the database will assign the next value automatically. In SQLite an integer id
field that has the PRIMARY KEY
constraint will auto increment by default!
Depending on how your database is set up, you may be using traditional id
s or you may be using UUIDs. SQL doesn't support auto incrementing a uuid
so if your database is using them your server will have to handle the changing uuid's for each record.
AUTO INCREMENT
in SQLiteWe are using traditional id
s in our database, so we can take advantage of the auto increment feature. Different dialects of SQL will implement this feature differently, but in SQLite any column that has the INTEGER PRIMARY KEY
constraint will auto increment! So we can omit the id
field within the INSERT
statement and allow the database to automatically add that field for us!
Let's add some more records into our users
table, but allow the database to automatically increment the id
field. Add the following records to the database:
name
: Lanceage
: 20country_code
: USusername
: LanChrpassword
: bootdevisbestis_admin
: falsename
: Tiffanyage
: 28country_code
: USusername
: Tifferoonpassword
: autoincrementis_admin
: trueFocus Editor
Alt+Shift+]
Next Tab
Alt+Shift+[
Next Tab
Alt+Shift+[
Become a member to Submit
Become a member to Run
Become a member to view solution