Subject | Re: Migrating database from MS SQL or PostgreSQL |
---|---|
Author | Andreas Tille |
Post date | 2000-08-17T14:23:38Z |
On Thu, 17 Aug 2000, Helen Borrie wrote:
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 ...
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.
> Oh - you want an SQL dump? (Sorry, I don't know anything about the PGYes, sorry, I should have noted that.
> tools, haven't gone near PostGresql yet).
> On Linux, use the isql program. The command you want is SHOW (variousHmm, with show I can get an SQL dump of a single table, view, etc.
> params, from DATABASE, for everything, down to TABLES with a parameter) -
> syntax in the Ops manual (I think).
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 areI think this is the right description for what it does. I like it very much.
> after - does this tool create some huge script of table creates and insert
> intos?
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.