pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Yet one more question
2+ messages / 1 participants
[nested] [flat]

* Yet one more question
@ 2001-01-16 05:12  Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Josh Berkus @ 2001-01-16 05:12 UTC (permalink / raw)
  To: pgsql-sql

Folks,

ALTER TABLE won't work until 7.1.  CUrrently, I have a table
that needs one small change, but it's refrenced as a foriegn
key by 7 other tables.  Any suggestions on how I can make
the table change without having to drop and re-create 8
tables?

-Josh Berkus



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Yet one more question
@ 2001-01-17 16:53  Josh Berkus <josh@agliodbs.com>
  parent: Josh Berkus <josh@agliodbs.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Josh Berkus @ 2001-01-17 16:53 UTC (permalink / raw)
  To: 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@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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-01-17 16:53 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-16 05:12 Yet one more question Josh Berkus <josh@agliodbs.com>
2001-01-17 16:53 ` Josh Berkus <josh@agliodbs.com>

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