This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes What is the difference between these two ways PostgreSQL)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "What is the difference between these two ways PostgreSQL)?" Watch "What is the difference between these two ways PostgreSQL)?" New topic
Author

What is the difference between these two ways PostgreSQL)?

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Hi.
What is the difference between:
insert into agents (id, username, password) values (default, '....', '....')
and
insert into agents (id, username, password) values (nextval('agents_seq'), '....', '....')
Where id column is auto increment (sequence)?
When to use each one?
Thanks.
Greg Bugaj
Greenhorn

Joined: May 19, 2008
Posts: 3
If I am not mistaken nextval('sequence name') will give you next available sequance number using specific sequence name, while the 'default' option will use the default associated sequence.
 
Consider Paul's rocket mass heater.
 
subject: What is the difference between these two ways PostgreSQL)?