dbTalk Databases Forums  

[newbie]?s: creating data-empty DB w/schema in place; pg_restore or psql -d

comp.databases.postgresql comp.databases.postgresql


Discuss [newbie]?s: creating data-empty DB w/schema in place; pg_restore or psql -d in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Anon432 Vqfz
 
Posts: n/a

Default [newbie]?s: creating data-empty DB w/schema in place; pg_restore or psql -d - 09-03-2009 , 02:17 PM






Hi:

Just learning postgresql, and SQL. Is this an appropriate
place to ask simple questions? If not pls direct me.

--
I have been asked to take a trivial test database 'test0' w/a single
table and a few rows of data, and:

- save only the non data portion of the database
( perhaps with pg_dump, if so with what switches, example pls )

- take the small archive created above, and restore it to an
new but structured database, w/schema in place but now data.
This database should be ready for data.
( perhaps using pg_restore or 'psql -d ..' )

--
thanks/regards,
T.
--
roa6v (AT) sdf (DOT) lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org

Reply With Quote
  #2  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: [newbie]?s: creating data-empty DB w/schema in place; pg_restore or psql -d - 09-04-2009 , 03:39 AM






Anon432 Vqfz wrote:
Quote:
Just learning postgresql, and SQL. Is this an appropriate
place to ask simple questions? If not pls direct me.
This place is appropriate for PostgreSQL and PostgreSQL's
dialect of SQL.

You should, however, not expect that people will solve your
homework for you, and you should be willing and ready to read
documentation. How else should you learn?

All your other questions can be easily answered by looking
up the documentation for pg_dump and psql in
http://www.postgresql.org/docs/current/static/
or alternatively by consulting the man pages of the
respective commands.

Yours,
Laurenz Albe

Reply With Quote
  #3  
Old   
Anon432 Vqfz
 
Posts: n/a

Default Re: [newbie]?s: creating data-empty DB w/schema in place; pg_restore or psql -d - 09-04-2009 , 02:29 PM



In article <1252053582.17 (AT) proxy (DOT) dienste.wien.at>,
Laurenz Albe <invite (AT) spam (DOT) to.invalid> wrote:
Quote:
Anon432 Vqfz wrote:
Just learning postgresql, and SQL. Is this an appropriate
place to ask simple questions? If not pls direct me.

This place is appropriate for PostgreSQL and PostgreSQL's
dialect of SQL.

You should, however, not expect that people will solve your
homework for you, and you should be willing and ready to read
documentation. How else should you learn?
Understood. I did read those man pages and ran some tests
yesterday. Here's a link w/the goal restated and a tiny test case:

http://schemaonlyrest0-qewbn.posterous.com

Any comments on above approach appreciated.

Today I tried the #postgresql on Freenode IRC channel and also learned about

http://pgsql.privatepaste.com/

Quote:
All your other questions can be easily answered by looking
up the documentation for pg_dump and psql in
http://www.postgresql.org/docs/current/static/
or alternatively by consulting the man pages of the
respective commands.
--
thx
T.

--
roa6v (AT) sdf (DOT) lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org

Reply With Quote
  #4  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: [newbie]?s: creating data-empty DB w/schema in place; pg_restore or psql -d - 09-07-2009 , 03:34 AM



Anon432 Vqfz wrote:
Quote:
Understood. I did read those man pages and ran some tests
yesterday. Here's a link w/the goal restated and a tiny test case:

http://schemaonlyrest0-qewbn.posterous.com

Any comments on above approach appreciated.
It is a bit hard to read, but I think I understood it.
Your approach should work fine.
The final pg_dump is for verification, right?

Here is what I would do differently:
- I would use -Fc instead of -Ft. The custom format is compressed
and more flexible.
- I would add the -s switch to pg_dump and not to pg_restore.
Why dump all the data if you only restore the object definitions?

Yours,
Laurenz Albe

Reply With Quote
  #5  
Old   
Name withheld by request
 
Posts: n/a

Default Re: [newbie]?s: creating data-empty DB w/schema in place; pg_restore or psql -d - 09-15-2009 , 08:39 PM



In article <1252312505.669020 (AT) proxy (DOT) dienste.wien.at>,
Laurenz Albe <invite (AT) spam (DOT) to.invalid> wrote:
Quote:
Anon432 Vqfz wrote:
Understood. I did read those man pages and ran some tests
yesterday. Here's a link w/the goal restated and a tiny test case:

http://schemaonlyrest0-qewbn.posterous.com

Any comments on above approach appreciated.

It is a bit hard to read, but I think I understood it.
Thanks for pushing thru. Re-reading my post I see a date
string that does not make sense; sorry - I just ran 'date' at the shell,
but that did not show up - my (pasting) mistake.

Quote:
Your approach should work fine.
Great. We tested it on a few copies of production databases, and
several quick checks ( looking at counts of tables, sequences, fumctions
...) looked just fine.

Quote:
The final pg_dump is for verification, right?
Right - I did not want to see any data in the final dump.

Quote:
Here is what I would do differently:
- I would use -Fc instead of -Ft. The custom format is compressed
and more flexible.
ok

Quote:
- I would add the -s switch to pg_dump and not to pg_restore.
Why dump all the data if you only restore the object definitions?
ok, restore what we saved, that's really what we want, so no -s

Quote:
Yours,
Laurenz Albe
I appreciate your help, thanks much.

--
T.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.