views:

306

answers:

2

Hi,

I have a posgreSQL database and I am using pgAdmin III to work with it.I created a sequence called primaryKeySequence.

Now I want to use this sequence as the default value for a primary key field in a table. I tried to insert

nextval('primaryKeySequence');

into the default value textfield in pgAdmin. When I click the 'OK'-button an error message comes up and says, that the sequence does not exist.

What is the right way, to do it?

Thanks in advance.

A: 

PostgreSQL is going to lowercase the identifier unless you "". So try:

nextval('primarykeysequence')

Also, you are doing it wrong. Use Serial/BigSerial instead.

Joshua D. Drake
A: 

Got it. Have a look here: pgadmin.org/docs/1.4/pg/functions-sequence.html The sequencename has to be quoted like this nextval('"primaryKeySequence"') because it is not lowercase

c0d3x