• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the difference between these two ways PostgreSQL)?

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic