Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: Perl DBI and Foreign Keys

by soonix (Canon)
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 chanting in the Monastery: (4)
As of 2024-04-25 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found