Re: Yet one more question - Mailing list pgsql-sql

From Josh Berkus
Subject Re: Yet one more question
Date
Msg-id 3A65CDEC.46BA1B6E@agliodbs.com
Whole thread Raw
In response to Yet one more question  ("Josh Berkus" <josh@agliodbs.com>)
List 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
informationtechnology      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


pgsql-sql by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Re: Boolean and Bit
Next
From: "Diehl, Jeffrey"
Date:
Subject: Help with query. (*)