On Thu, Oct 21, 2010 at 12:03, Alex Hunsaker <bada...@gmail.com> wrote: > Or if you just want the not null constraints: > create table kittu1 (like kota1 including constraints);
Correction, the above should read: "Or, if you want check constraints". Not null constraints are always copied, and including constraints only deals with check constraints. On Thu, Oct 21, 2010 at 22:01, KOTAPATI KRISHNAIAH <kotapati.kris...@hotmail.com> wrote: [ Example shrunk ] > CREATE TABLE cons > ( > id integer NOT NULL primary key, > ); > > The above cons table already existed. > when i'm creating the above same structure of table by using below this > Query i'm not getting constraints ... > > create table vijju1(like cons including constraints); > > CREATE TABLE vijju1 > ( > id integer NOT NULL, > ); Or in other words create table like is not copying the primary key constraint. The simple answer is to use "including indexes". There is quite a bit of discussion on this, some interesting points: http://archives.postgresql.org/pgsql-hackers/2009-12/msg02018.php and a long thread with a patch...: http://postgresql.1045698.n5.nabble.com/CREATE-TABLE-LIKE-INCLUDING-INDEXES-support-td2220980.html The sad news is I dont think anything appened for 8.4 or 9.0. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs