| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Primary Key Theory Question
Em Sun, 28 Mar 2004 21:53:07 +0000, Ben escreveu:
> _how_ does one
> generate a surrogate key that is a) unique and b) usable from an
> application programmer's point of view.
For the programmers, SEQUENCEs are about as good as it gets. PostgreSQL's serial is also good. I am not familiar with SQL Servers' identity...
Now obviously any surrogate key alone *is* a recipe for disaster. That's why one needs still to implement uniqueness constraints for the natural candidate keys. Surrogates are only to keep programmers and users from whining about composite keys.
> sequences and Identity columns are great from an application developers
> point of view because you have easy access to the key of a newly created
> record.
Sequences are nice too, SELECT sequence.nextval FROM dual;
-- Leandro Guimarães Faria Corsetti Dutra <leandro_at_dutra.fastmail.fm> Maringá, PR, BRASIL http://br.geocities.com./lgcdutra/ Soli Deo Gloria!Received on Tue Mar 30 2004 - 14:47:15 CST
![]() |
![]() |