Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: An improved technique for database primary keys

by duelafn (Parson)
on Nov 05, 2010 at 05:15 UTC ( [id://869624]=note: print w/replies, xml ) Need Help??


in reply to An alternate technique for database primary keys

Some databases can handle this directly:

psql> CREATE SEQUENCE foo; psql> CREATE TABLE bar ( id char(10) PRIMARY KEY DEFAULT 'bar_' || nextval('foo') , name text ); psql> INSERT INTO bar (name) VALUES ('Alice'); psql> INSERT INTO bar (name) VALUES ('Bob'); psql> SELECT * FROM bar; id | name ------------+------- bar_1 | Alice bar_2 | Bob

Good Day,
    Dean

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-20 00:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found