5

how can i detach a primary key of table from a sequence with out having to drop the table

1
  • Programmatically, or with an admin utility? Commented Apr 30, 2015 at 13:10

1 Answer 1

5

With "detach" you mean probably, removing the default for the column to the next value of the sequence. For example, say you have a table definition like this:

 Column   |  Type   |                           Modifiers                            
------------+---------+----------------------------------------------------------------
 yourcolumn | integer | not null default nextval('yourtable_yourcolumn_seq'::regclass)

you want to remove this part: default nextval('yourtable_yourcolumn_seq'::regclass)

If so, you can do it with this statement:

ALTER TABLE yourtable ALTER COLUMN yourcolumn DROP DEFAULT;
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, that was what I was looking for, an ALTER query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.