Subject Re: Migrating database from MS SQL or PostgreSQL
Author Andreas Tille
On Thu, 17 Aug 2000, Helen Borrie wrote:

> Oh - you want an SQL dump? (Sorry, I don't know anything about the PG
> tools, haven't gone near PostGresql yet).
Yes, sorry, I should have noted that.

> On Linux, use the isql program. The command you want is SHOW (various
> params, from DATABASE, for everything, down to TABLES with a parameter) -
> syntax in the Ops manual (I think).
Hmm, with show I can get an SQL dump of a single table, view, etc.
pg_dump does the following way of backing up a database:
Generation of a complete SET of SQL functions which restore the
database definition and data.
For instance
pg_dump <my_db> > my_db.dump
could be (theoretically) filed as script into isql and would create the
database <my_db> in InterBase. Well, theoretically means that there
are some incompatibilities :-(.
If I want to restore a complete database I just do
cat my_db.dump | psql
where psql (the pendant to isql) runs the dump as SQL script.
Unfortunately it doesn't work for isql in the case of the data,
because isql lacks the COPY feature, which means

COPY "table" FROM stdin;
1 item1 \N
2 item2 \N

which is PostgreSQLs way to import data. Anyway, I plan to fiddle around
a little bit with sed (or perl) to transform the COPYs into INSERT statements.
May be I would have some luck ...

> Does your pg_dump deliver a script? Still can't figure out what you are
> after - does this tool create some huge script of table creates and insert
> intos?
I think this is the right description for what it does. I like it very much.

By the way: To increase usability it might be a good idea to look at the
psql sources. The libreadline library does a very good job there ...

Kind regards

Andreas.