On 1 Apr 2015, at 2:19am, Kumar Suraj <surajnitk at gmail.com> wrote:

> I am using sqlite C interface for inserting data in the table. The primary
> key is a 64 bit integer which i need to auto-increment and get populated
> automatically as we do not provide that value in insert statement. Is there
> a way i can get the autoincremented value for each row inserted when ever i
> execute my insert.

[explanation simplified because I don't want to have to type three pages]

SQLite does this automatically if you do not declare a primary key for a table. 
 It will create an INTEGER column called 'rowid' for you and increment the 
value for each row you enter.  You will never see that column unless you ask 
for it explicitly by doing something like

SELECT rowid,* FROM myTable LIMIT 10;

but it's a real column and you can select, search and sort on it just like any 
other INTEGER column.  If you have already created your table try the above 
statement on it.

Alternatively you can follow the instructions from FAQ 1 on this page:

<https://www.sqlite.org/faq.html>

This does more or less the same thing, with the advantage that you can specify 
your own name for the column.

Simon.

Reply via email to