Re: How to "COPY schema1.table TO schema2.table" ?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Tim Goodaire <tgoodaire(at)linux(dot)ca>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to "COPY schema1.table TO schema2.table" ?
Date: 2005-02-03 01:12:04
Message-ID: 20050203011204.GA32100@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message John DeSoi 2005-02-03 02:01:38 Re: Calling psql from a bat file on windows?
Previous Message Ron Mayer 2005-02-02 23:50:35 Vacuum strategy for a frequently rebooted system?