Thread: create table like . . . constraint names

create table like . . . constraint names

From
"Sahagian, David"
Date:
Is there any way for me to control the name of the (unique or primary) constraints that get created when doing a “create table like parent-table” statement ?
 
I use this statement to create the new table in a different schema than the one in which the parent-table lives, and I would like the constraint names to be the same as those of the parent-table.
 
thanks,
-dvs-
 

Re: create table like . . . constraint names

From
Vincent Veyron
Date:
Le vendredi 24 août 2012 à 09:27 -0400, Sahagian, David a écrit :
> Is there any way for me to control the name of the (unique or primary)
> constraints that get created when doing a “create table like
> parent-table” statement ?

I suppose that you use 'INCLUDING CONSTRAINTS' in your LIKE clause,
since constraints are copied?

You can drop the constraint and re-create it with the name you want :

http://www.postgresql.org/docs/9.1/static/sql-altertable.html


--
Vincent Veyron
http://vincentveyron.com/
Gestion informatique des sinistres d'assurances et des dossiers contentieux pour le service juridique