473,395 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DDL for a single schema

Is there a way to get a dump of all the DDL and data associated with a
single schema within a database?

What I tried in attempting to hack this out was

\dt consume.*

and

\dv consume.*

to get a list of tables and views in the schema named "consume", then
sent those lists to a file "tables.txt". Followed that with something
like

for n in `cat tables.txt` do; pg_dump -t $n >> consume.sql; done

This almost worked, except for that I have some duplicate table names in
other schemas, and the pg_dump picked up both the table I wanted in the
consume schema and the the similarly-named table in a different schema.
I'd really like to be able to get the complete dump for one schema and no
more. Might work if you could specify a schema-qualified table name in
the -t option of pg_dump, but that apparently is not possible currently.

I tried also using pg_restore to generate a list file, thinking I could
edit the output list file to include only the tables from desired schema.
This would really be a better approach than what I've show above, but
having the duplicate table names was again the problem because nothing in
the list file distinquishes which schema the tables are members of.

~Berend Tober


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #1
6 3079
On Friday 07 November 2003 18:53, bt****@seaworthysys.com wrote:
Is there a way to get a dump of all the DDL and data associated with a
single schema within a database?

What I tried in attempting to hack this out was

\dt consume.*

and

\dv consume.*

to get a list of tables and views in the schema named "consume", then
sent those lists to a file "tables.txt". Followed that with something
like

for n in `cat tables.txt` do; pg_dump -t $n >> consume.sql; done


pg_dump in 7.4 has the dump option. You need to use --schema as option.

Check developers documentation on web site or download RC1 and try out
yourself.

HTH

Shridhar
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #2
On Friday 07 November 2003 19:36, Shridhar Daithankar wrote:
On Friday 07 November 2003 18:53, bt****@seaworthysys.com wrote:
Is there a way to get a dump of all the DDL and data associated with a
single schema within a database?

What I tried in attempting to hack this out was

\dt consume.*

and

\dv consume.*

to get a list of tables and views in the schema named "consume", then
sent those lists to a file "tables.txt". Followed that with something
like

for n in `cat tables.txt` do; pg_dump -t $n >> consume.sql; done


pg_dump in 7.4 has the dump option. You need to use --schema as option.

Check developers documentation on web site or download RC1 and try out
yourself.


http://developer.postgresql.org/docs...pp-pgdump.html

Sorry for missing it first time..

Shridhar
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #3
On Friday 07 November 2003 19:36, Shridhar Daithankar wrote:
On Friday 07 November 2003 18:53, bt****@seaworthysys.com wrote:
> Is there a way to get a dump of all the DDL and data associated

with a single schema within a database?
pg_dump in 7.4 has the dump option. You need to use --schema as
option.

Check developers documentation on web site or download RC1 and try
out
yourself.


http://developer.postgresql.org/docs...pp-pgdump.html

Sorry for missing it first time..

Shridhar


Thanks. Didn't have immediate plans to upgrade from 7.3. But I'll look
for that feature when the time comes.

~Berend Tober


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #4
On Friday 07 November 2003 14:28, bt****@seaworthysys.com wrote:
On Friday 07 November 2003 19:36, Shridhar Daithankar wrote:
On Friday 07 November 2003 18:53, bt****@seaworthysys.com wrote:
> Is there a way to get a dump of all the DDL and data associated

with a single schema within a database?
pg_dump in 7.4 has the dump option. You need to use --schema as
option.
Thanks. Didn't have immediate plans to upgrade from 7.3. But I'll look
for that feature when the time comes.


I believe 7.4 pg_dump should work against a 7.3 database (and further back
IIRC).
--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #5
Richard Huxton <de*@archonet.com> writes:
I believe 7.4 pg_dump should work against a 7.3 database (and further back
IIRC).


It will, but I don't think we guarantee that the output will load into a
pre-7.4 database --- pg_dump usually assumes its SQL output can take
advantage of all the features it knows about.

This might work more-or-less-okay for 7.3, but you'd better test before
depending on it.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #6
On Fri, 2003-11-07 at 08:23, bt****@seaworthysys.com wrote:
Is there a way to get a dump of all the DDL and data associated with a
single schema within a database?


The 7.4 pg_dump is capable of this task (--schema=SCHEMA) but you may
have difficulties restoring to a 7.3 backend.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQA/q6Tu6DETLow6vwwRAjDsAJ98PhoDxt7/tL7eRBqe1RjUo54figCggtVi
NFduLYHXxPzQzJJe5u8QxX0=
=jNcb
-----END PGP SIGNATURE-----

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kyancy | last post by:
Hello All. We have several XML schemas to describe common component document parts. We then create new XML schemas as necessary that use "xsd:import schemaLocation=whateverLocation.." to include...
1
by: John Smith | last post by:
Ok, I have 2 xml files that are really similar. They have the exact same structure exept that in one XML some element are required and in the other they are simply absent from the xml. Problem...
3
by: John Smith | last post by:
Ok, I am not sure if it is possible. But what I'm trying to do is validate an XML file with out having to add namespace in the xml. What I mean is lets say I have 2 XSD they have different...
2
by: Tarren | last post by:
Hi: The problem I am having is when I validate an xml file to a schema, it is erroring out every element. I think this has something to do with me defining/referencing the namespaces. I have...
19
by: Steve Jorgensen | last post by:
I've run across this issue several times of late, and I've never come up with a satisfactory answer to the best way to handle this schema issue. You have a large section of schema in which a...
1
by: Wallace | last post by:
Hi all, I have a problem on validating a xml fragment using a single namespace schema which spread across multiple schema files using include in the master schema file. No matter how I change...
2
by: jjouett | last post by:
We are starting to setup some Web Services to provide our customers with a way to programatically interact with our application, and some of our customers have slightly different requirements in...
5
by: BMeyer | last post by:
I have been losing my mind trying to parse an XML document (with nested child elements, not all of which appear in each parent node) into a DataGrid object. What I want to do is "flatten" the XML...
2
by: Bardo | last post by:
Hi all, Does anyone know if it is possible, and if so how, to perform validation of a simple non XML string against certain XSD restrictions, without having the entire XML document to validate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.