Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^5: Perl DBI and Foreign Keys

by soonix (Chancellor)
on Apr 08, 2019 at 14:32 UTC ( [id://1232297]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Perl DBI and Foreign Keys
in thread Perl DBI and Foreign Keys

You will see that the ScoreCard table winds up containing an extra field, "rowid" that I didn't specify in CREATE TABLE ScoreCard.
That is SQLite specific, documented under https://sqlite.org/lang_createtable.html#rowid
Except for WITHOUT ROWID tables, all rows within SQLite tables have a 64-bit signed integer key that uniquely identifies the row within its table. …
BTW SQLite's last_insert_rowid() documentation explicitly refers to "the database connection which invoked the function", so should work with multiple parallel insertions.

Replies are listed 'Best First'.
Re^6: Perl DBI and Foreign Keys
by dsheroh (Monsignor) on Apr 09, 2019 at 07:27 UTC
    Yeah, rowid is SQLite-specific, but most[citation needed] major database engines will generate some kind of hidden unique identifier for each row if there isn't one explicitly specified. I believe this is because it's much harder to implement joins between tables which completely lack any way to uniquely identify rows. (I read something along those lines many years ago, but haven't really looked into it in any detail.) IIRC, MySQL and Postgres use UUIDs for this purpose and, of course, the field names involved will be engine-specific (if they're user-accessible at all).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232297]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2025-07-14 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.