Kevin
Kevin

Reputation: 195

Select ID in SQLite

I am trying to make a function that can select id from my database table and I have some questions.

Q1 : If I insert 5 data in my database and i delete from the second data. What is the ID be when i insert the next data ?

Table sample :

───
ID | NAME |
───
0 | A |
───
1 | B |
───
2 | C |
───
3 | D |
───
4 | E |
───

if i delete ID == 1 what is the next ID when i insert next new data Name is F?

Q2 : When I Select numID(int) as my table ID(Primary key) from TABLE but if this ID num doesn't exist what will happen when i run the code ?

Q3 : If i select a random integer as ID ( size <= SQLite queryNumEntries ) , how can i do to avoid selecting ID what doesn't exist ?

Upvotes: 1

Views: 560

Answers (1)

chiru
chiru

Reputation: 645

Q1: If ID column is Auto Incremental, then when you delete any row your next id will be incremented even if you delete last row (i.e. if you delete 6th row then next row ID will be 7)

Q2: Throws exception Column does not exist.

Q3: Returns empty rows

Upvotes: 1

Related Questions