Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Howto set sequence as default value via pgAdmin?

Tags:

pgadmin

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?

like image 911
c0d3x Avatar asked Feb 14 '10 15:02

c0d3x


People also ask

How do I change the default value in pgAdmin?

Set Column Default using pgAdmin In the popup, go to 'Columns' tab and click on the edit icon againt a column to change the default value, as shown below. Now, go to the 'Constraints' tab and set or change the default value. Click on the Save button to save the changes.

What is sequence default start with value?

The default starting value is minvalue for ascending sequences and maxvalue for descending ones.

How do you create a sequence in pgAdmin 4?

Click the Definition tab to continue. Use the fields in the Definition tab to define the sequence: Use the Increment field to specify which value is added to the current sequence value to create a new value. Provide a value in the Start field to specify the beginning value of the sequence.


1 Answers

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

like image 183
c0d3x Avatar answered Oct 02 '22 01:10

c0d3x