And, only if you assign your own name to the column can you use it in foreign 
key constraints ...


---
Theory is when you know everything but nothing works.  Practice is when 
everything works but no one knows why.  Sometimes theory and practice are 
combined:  nothing works and no one knows why.


>-----Original Message-----
>From: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-
>bounces at mailinglists.sqlite.org] On Behalf Of Simon Slavin
>Sent: Tuesday, 31 March, 2015 19:26
>To: General Discussion of SQLite Database
>Subject: Re: [sqlite] insert in sqlite (returning value for inserted row)
>
>
>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.
>_______________________________________________
>sqlite-users mailing list
>sqlite-users at mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



Reply via email to