Re: Yet one more question

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Yet one more question
Date: 2001-01-17 16:53:00
Message-ID: 3A65CDEC.46BA1B6E@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)agliodbs(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ross J. Reedstrom 2001-01-17 17:14:26 Re: outer join in PostgreSql
Previous Message Josh Berkus 2001-01-17 16:36:21 Re: Re: Boolean and Bit