primary key quinky dink

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

primary key quinky dink

dboland9
I have created a number of tables, and two of then are part of a many to many relationship. Thus, I need to get the last row id.  Using the browser, I find that:
     mytable_id INTEGER AUTO_INCREMENT PRIMARY KEY produces a null value
    mytable_id INTEGER PRIMARY KEY produces an integer value.

So, AUTO_INCREMENT should not be used for a primary key?  I have seen it used in some examples on the Internet (yes, I know, don't believe everything I read).  Will the table still auto number?

Dave,

Sent with [ProtonMail](https://protonmail.com) Secure Email.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: primary key quinky dink

Simon Slavin-3
On 19 Aug 2019, at 6:56pm, dboland9 <[hidden email]> wrote:

> I have created a number of tables, and two of then are part of a many to many relationship. Thus, I need to get the last row id.  Using the browser,

What browser ?  No part of the SQLite distribution is called a browser.

> I find that:
>     mytable_id INTEGER AUTO_INCREMENT PRIMARY KEY produces a null value
>    mytable_id INTEGER PRIMARY KEY produces an integer value.
>
> So, AUTO_INCREMENT should not be used for a primary key?

I think you have the right idea but a wrong syntax.

<https://sqlite.org/faq.html#q1>

My guess is that you want

    mytable_id INTEGER PRIMARY KEY
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: primary key quinky dink

dboland9
That is what I am using.  Thanks for the pointer to the FAQ.

Dave,


Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, August 19, 2019 2:15 PM, Simon Slavin <[hidden email]> wrote:

> On 19 Aug 2019, at 6:56pm, dboland9 [hidden email] wrote:
>
> > I have created a number of tables, and two of then are part of a many to many relationship. Thus, I need to get the last row id. Using the browser,
>
> What browser ? No part of the SQLite distribution is called a browser.
>
> > I find that:
> > mytable_id INTEGER AUTO_INCREMENT PRIMARY KEY produces a null value
> > mytable_id INTEGER PRIMARY KEY produces an integer value.
> > So, AUTO_INCREMENT should not be used for a primary key?
>
> I think you have the right idea but a wrong syntax.
>
> https://sqlite.org/faq.html#q1
>
> My guess is that you want
>
> mytable_id INTEGER PRIMARY KEY
>
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: primary key quinky dink

Simon Slavin-3
On 19 Aug 2019, at 7:20pm, dboland9 <[hidden email]> wrote:

> That is what I am using.

I'm sorry.  I missed that.  Yes, you have the right solution now.  I don't know where you got "AUTO_INCREMENT" from but it's not part of SQLite.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users