[postgis-users] copying tables from one schema to another

Robert Buckley robertdbuckley at yahoo.com
Thu Sep 22 04:29:09 PDT 2011


Hi,

As a follow-up to my earlier post (Re: [postgis-users] schemas and postgis data) I have another question.

I had originally put all my data into the public schema. I want to move my geodata to the schema "data", so I just used to following command in the pgadmin3 sql editor

create table data.new_table as (select * from public.old_table);

although this works, the schema is not copied..ie the primary key and other contraints are missing.

So i have done this

# first create new table and copy schema
create table data.table_2(like table_1 including defaults including constraints including indexes);

#then copy data into table_2
insert into data.table2(select * from public.table_1);

Is there a better/quicker/safer way of doing this? possibly with pgadmin3?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20110922/c0591434/attachment.html>


More information about the postgis-users mailing list