create table like . . . constraint names

Started by Sahagian, Davidover 13 years ago2 messagesgeneral
Jump to latest
#1Sahagian, David
david.sahagian@emc.com

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-

#2Vincent Veyron
vv.lists@wanadoo.fr
In reply to: Sahagian, David (#1)
Re: create table like . . . constraint names

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