Batching multiple CREATE TABLE commands - Mailing list pgsql-general

From Richard Huxton
Subject Batching multiple CREATE TABLE commands
Date
Msg-id 419DBE24.3080903@archonet.com
Whole thread Raw
In response to Re: How to make a good documentation of a database ?  (Nageshwar Rao <NageshwarR@PLANETASIA.COM>)
List pgsql-general
Nageshwar Rao wrote:
> Hi,
> I have set of create table statements. I need to execute them at one go
> instead of running individual statement to create a table.
> Help !

Nageshwar - two tips for posting to the mailing lists
  1. Don't reply to an existing message with a new question
  2. Make sure the subject line describes your question.
Otherwise, many people won't notice your question and you'll get less
people able to help.

As to the best way of executing multiple CREATE TABLE statements, that
depends on whether you are using psql or some other client. With psql
I'd put the statements in a file, then use something like:
   psql -f my_commands.sql
   psql < my_commands.sql
Or, if you're logged into psql you could use:
   \i my_commands.sql
All covered in the man page for psql.

I always wrap the whole lot in BEGIN ... COMMIT so that if (usually
when) I make a mistake it rolls back all the changes.

HTH
--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: "Premsun Choltanwanich"
Date:
Subject: How to make lo_import and lo_export to use file on client local machine?
Next
From: jseymour@linxnet.com (Jim Seymour)
Date:
Subject: Re: pgEdit public beta for Macintosh and Windows