mirror of https://github.com/postgres/postgres
Submitted by: david bennett <dave@bensoft.com> marc g. fournier <scrappy@ki.net>Release_1_0_3
parent
e72ca17f77
commit
d602a35d37
@ -0,0 +1,48 @@ |
||||
|
||||
This is a modified version of the pg_dump.c program that is distributed with |
||||
pg95 1.01. Modifications include: |
||||
|
||||
* Applied 'insert string' patch from "Marc G. Fournier" <scrappy@ki.net> |
||||
|
||||
(see insert.patch & README.scrappy for info on this patch) |
||||
|
||||
* Added '-t table' option |
||||
|
||||
By specifying '-t table' on the command line you can output only the |
||||
schema (table & index defs) and data for one table of a database. |
||||
|
||||
Example: |
||||
|
||||
pg_dump -t descriptions software |
||||
|
||||
* Added '-a' option |
||||
|
||||
This is the opposite of the -S option. By specifying -a you can output |
||||
only the database data and not the schema. |
||||
|
||||
Example: |
||||
|
||||
pg_dump -a zipcodes |
||||
|
||||
* Added '-da' option |
||||
|
||||
Marc's '-d' option adds the ability to output insert strings, By using |
||||
the 'a' sub-parameter you can also place the attribute names in the |
||||
insert strings. Basically, this is useful because ALTER TABLE is |
||||
broken in pg95 1.01. |
||||
|
||||
NOTE: This will create some long hairy output files! Be sure to pipe |
||||
through compress or gzip before outputing to disk. |
||||
|
||||
Example: |
||||
|
||||
pg_dump -da -t oldfile mydatabase | gzip > oldfile.data.gz |
||||
|
||||
Comments: |
||||
|
||||
----------------------------------------------------- |
||||
David Bennett, Bennett Software Solutions |
||||
2608 NW Fawn Drive Blue Springs, MO 64015 |
||||
Phone: 816-228-8788, Fax: 816-228-3204 |
||||
dave@bensoft.com, http://bensoft.com |
||||
PGP key at ftp://bensoft.com/pub/pgp/daveskey.txt |
@ -0,0 +1,23 @@ |
||||
Here is what Marc had to say about insert.patch included in this archive.... |
||||
|
||||
In preparation of finally moving all my 1.0 databases over to a 1.01 |
||||
database server, I looked at pg_dump and found that, unless I missed |
||||
something, it didn't *easily* do what I wanted, which was to dump a database |
||||
to a file, and then reload it again on another server (short-term)...but, |
||||
also, there doesn't seem to be any mechanism for dumping the database to a |
||||
file that can be backed up and quickly reloaded again. |
||||
|
||||
So, I spent the past several hours modifying pg_dump so that it has an extra |
||||
switch for dumping the data in valid 'insert' strings, so that you can |
||||
quickly and easily reload a database. |
||||
|
||||
So, now the output looks like: |
||||
|
||||
CREATE TABLE scrap (integer int4, real float4, text text) archive = none; |
||||
insert into scrap values (1, 1, 'text'); |
||||
|
||||
Now, the hard part was figuring out what types are available, so that the |
||||
insert string works properly for char vs numberic data fields. As such, the |
||||
switch statement I'm using in dumpClasses() for this may be missing values |
||||
for numeric fields (I'm using PQftype() to figure out numeric vs non-numeric |
||||
fields) |
Loading…
Reference in new issue