Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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

nextval('primarykeysequence')

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top