Обсуждение: this is postgresql question..how do i drop unique constraint on a column?

Поиск
Список
Период
Сортировка

this is postgresql question..how do i drop unique constraint on a column?

От
Eugene Kim
Дата:
content in content table has unique constraint..(although i can't see it
with \d content)

how can i drop that constraint?
thank you

mydb=# \d content
           Table "content"
    Attribute    |  Type   | Modifier
-----------------+---------+----------
 content_id      | integer | not null
 content         | text    | not null
 title           | text    |
 description     | text    |
 content_type_id | integer | not null
Indices: content_content_key,
         content_pkey

mydb=#


Re: this is postgresql question..how do i drop unique constraint on a column?

От
Jan Ploski
Дата:
On Fri, Sep 06, 2002 at 03:12:09AM +0000, Eugene Kim wrote:
> content in content table has unique constraint..(although i can't see it
> with \d content)
>
> how can i drop that constraint?

Eugene,

first, you need to figure out the constraint's name:

select c.relname from pg_class c, pg_index i where
    i.indrelid=(select oid from pg_class where relname='content') and
    c.oid=i.indexrelid and i.indisunique='t';

Then use "drop index <name>" to drop it.

For more info about accessing database metadata, see Developer's Guide,
chapter "System Catalogs".

-JPL


Re: this is postgresql question..how do i drop unique constraint on a column?

От
snpe
Дата:
7.3 beta list foreign key with
\d <table_name>
and drop it with
alter table <table_name> drop constraint <constraint_name>

regards
Haris Peco
On Monday 09 September 2002 04:48 pm, Jan Ploski wrote:
> On Fri, Sep 06, 2002 at 03:12:09AM +0000, Eugene Kim wrote:
> > content in content table has unique constraint..(although i can't see it
> > with \d content)
> >
> > how can i drop that constraint?
>
> Eugene,
>
> first, you need to figure out the constraint's name:
>
> select c.relname from pg_class c, pg_index i where
>     i.indrelid=(select oid from pg_class where relname='content') and
>     c.oid=i.indexrelid and i.indisunique='t';
>
> Then use "drop index <name>" to drop it.
>
> For more info about accessing database metadata, see Developer's Guide,
> chapter "System Catalogs".
>
> -JPL
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly