creating tables from a disk file

From: Lee Kindness <lkindness(at)csl(dot)co(dot)uk>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: creating tables from a disk file
Date: 2002-02-19 16:37:42
Message-ID: 15474.32598.991337.623234@kelvin.csl.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Simply use psql and redirection...

createdb database
psql database < create-tables.sql

Just ensuring your statements are ';' terminated or '\g' terminated,
but not both!

Regards, Lee Kindness.

Rich Shepard writes:
> I have created the database schema as a text file. It contains all the
> CREATE TABLE comands with the fields and their constraints. But, I cannot
> find a command that will have postgres accept this file and create the
> tables for me.
>
> The COPY (\copy) commands are only for data and so is INSERT. CREATE TABLE
> does not appear to have an option by which a disk file can be specified.
>
> Is there a way of having the postmaster read the specifications and create
> the tables, or do I re-enter them all from within psql?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-02-19 16:41:33 Re: pg_dump correct version?
Previous Message Rich Shepard 2002-02-19 16:34:49 Re: libpq or ecpg?