pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: pgsql-sql@postgresql.org
Subject: Re: Yet one more question
Date: Wed, 17 Jan 2001 08:53:00 -0800
Message-ID: <3A65CDEC.46BA1B6E@agliodbs.com> (raw)
References: <web-1177586@davinci.ethosmedia.com>
	<3A64543B.154F29B0@bigpond.net.au>

Justin,

> How do you do the "drop and create" of tables?

1. Save table definition as text.

2. Create a duplicate of the table definition as "temp_table"

3. INSERT all of the table records into the temp_table

4. DROP the existing table

5. Re-CREATE the table with the altered definition.

6. INSERT the rows from the temp_table back into the table.

Of course, this process fails to preserve SERIAL keys, FORIEGN KEYS,
etc. and is somewhat labor intensive.  ANybody create a script to do
this dynamically?

> I use pg_dump -d <dbname> > something.sql
> 
> Then I use vi/sed/something-else to modify the schema in the dumped
> file,
> then reload it into postgreSQL with psql -e <dbname> < something.sql >
> /dev/null

Thanks.  SOunds like a good alternate strategy, although it still blows
away our test data.  I'd also need to see if our functions survive the
dump ...

					-Josh Berkus
-- 
______AGLIO DATABASE SOLUTIONS___________________________
                                        Josh Berkus
   Complete information technology      josh@agliodbs.com
    and data management solutions       (415) 436-9166
   for law firms, small businesses       fax  436-0137
    and non-profit organizations.       pager 338-4078
                        		San Francisco



view thread (2+ messages)

Message-ID: <3A65CDEC.46BA1B6E@agliodbs.com>
Permalink:  ../3A65CDEC.46BA1B6E@agliodbs.com/
Also on:    postgresql.org/message-id/3A65CDEC.46BA1B6E@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com
  Subject: Re: Yet one more question
  In-Reply-To: <3A65CDEC.46BA1B6E@agliodbs.com>
  References: <web-1177586@davinci.ethosmedia.com> <3A64543B.154F29B0@bigpond.net.au> <3A65CDEC.46BA1B6E@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox