Reputation: 1500
how can i detach a primary key of table from a sequence with out having to drop the table
Upvotes: 5
Views: 1971
Reputation: 6878
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;
Upvotes: 5