Re: How to "COPY schema1.table TO schema2.table" ? - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: How to "COPY schema1.table TO schema2.table" ?
Date
Msg-id 20050203011204.GA32100@winnie.fuhr.org
Whole thread Raw
In response to Re: How to "COPY schema1.table TO schema2.table" ?  (Tim Goodaire <tgoodaire@linux.ca>)
List pgsql-novice
On Wed, Feb 02, 2005 at 02:58:35PM -0500, Tim Goodaire wrote:

> You can copy a table from one schema to another by doing something like
> this:
>
> SET search_path TO schema1,schema2;

This isn't necessary for the CREATE TABLE statement below since
you're already using schema-qualified table names.  There might be
other reasons for doing so, however.

> CREATE TABLE schema2.mytable AS SELECT * FROM schema1.mytable;

Note that this copies only data -- you won't get constraints, default
values, indexes, triggers, rules, etc.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-novice by date:

Previous
From: Andrew Hammond
Date:
Subject: Re: grant all the database object automatically
Next
From: John DeSoi
Date:
Subject: Re: Calling psql from a bat file on windows?