Re: how can i change my table/column constraint

From: Anand Raman <araman(at)india-today(dot)com>
To: postgres general <pgsql-general(at)postgresql(dot)org>
Subject: Re: how can i change my table/column constraint
Date: 2001-05-05 07:18:59
Message-ID: 20010505124859.C27834@india-today.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

basically copy the table to some other table..
Drop the old table..
recreate it with the constraints changed
Repopulate the table..

Hope this helps
Anand

On Sat, May 05, 2001 at 01:49:31PM +0700, Muhammad Rusydi wrote:
>Hi,
>if i have created this tables:
>create table lab (
>kd_lab varchar(4) check (kd_lab ~'[0][1-4][0-9][0-9]'),
>name varchar(10),
>primary key (kd_lab));
>
>create table tb2 (
>kd_lab varchar(4) references lab (kd_lab),
>tb2 varchar(10),
>primary key (kd_lab));
>
>the questions is if i want to change the check constraint to
>[0][1-5][0-9][0-9]
>how can i do this?
>if i create another table named lab2 with same fields and then i move
>all tuples from lab to lab2, then drop table lab and rename lab2 to
>lab, is the references constraint in table tb2 still valid?
>would you show me how to do this?
>
>TIA
>Didi
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Muhammad Rusydi 2001-05-05 08:18:37 Re: how can i change my table/column constraint
Previous Message Muhammad Rusydi 2001-05-05 06:49:31 how can i change my table/column constraint