Home » SQL & PL/SQL » SQL & PL/SQL » surrogate key
surrogate key [message #187054] Thu, 10 August 2006 12:51 Go to next message
sonia_sonia
Messages: 1
Registered: August 2006
Junior Member
hi all,
does anyone know how to create surrogate key using pl/sql.I cant find any suitable example on the net.
please anyone who can help
Thank-you Razz
Re: surrogate key [message #187057 is a reply to message #187054] Thu, 10 August 2006 13:00 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
use a SEQUENCE
Re: surrogate key [message #187299 is a reply to message #187054] Fri, 11 August 2006 14:09 Go to previous messageGo to next message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
I used the search words "surrogate key oracle" on google and it returned 123000 hits. Try it your self.
Re: surrogate key [message #201958 is a reply to message #187299] Tue, 07 November 2006 10:22 Go to previous messageGo to next message
anonymous.nospam
Messages: 2
Registered: November 2006
Junior Member
Use the following command to create a sequence called MySequence:

CREATE SEQUENCE MySequence;

Each time you use MySequence.NextVal you will get a new value. For example:

INSERT INTO MyTable(id,name)
VALUES (MySequence.NextVal,'John Do');

You can read the pros and cons of surrogate keys in this thread.

Hope it helps...
Re: surrogate key [message #201962 is a reply to message #201958] Tue, 07 November 2006 10:28 Go to previous message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

http://asktom.oracle.com/pls/ask/f?p=4950:8:16554651565849651781::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:6723299263475


i already too late...
Previous Topic: automatically populate UID field
Next Topic: what should i do?? - hints?
Goto Forum:
  


Current Time: Fri Dec 09 08:00:20 CST 2016

Total time taken to generate the page: 0.12217 seconds