dbTalk Databases Forums  

Re: Join between databases or (???)

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss Re: Join between databases or (???) in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Net Virtual Mailing Lists
 
Posts: n/a

Default Re: Join between databases or (???) - 11-20-2004 , 08:37 PM






I suspect that schemas are the best way to go, but gosh is it going to be
a bear to re-engineer all this stuff... Unfortunately it was all done in
the "pre-schema" days of Postgres and just evolved from there.....

If I want to take an existing table and add it into a schema is it
basically "alter database [database] rename [table] to schema.[table]"?....

... I guess that I was just looking for confirmation there was not
something in postgres which would allow this "full featured cross-
database join" before pulling an a few all nighters...

Thanks!

- Greg

Quote:
On Sat, Nov 20, 2004 at 06:09:49PM -0700, Net Virtual Mailing Lists wrote:

I have situation where multiple databases need to use data from a common
source and it would consume way too much disk space to reproduce this
data into the many databases which require it. Is there some way to do a
join between databases or some other way of making the data in one
database available in another in a space-efficient manner? Of course it
is necessary that if this is possible any queries need to take advantage
of indexes/etc.

You could use dblink but it might not provide all the functionality
you're looking for. Could the multiple databases possibly be converted
into multiple schemas in the same database?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/



---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
  #2  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: Join between databases or (???) - 11-20-2004 , 09:03 PM






On Sat, Nov 20, 2004 at 06:09:49PM -0700, Net Virtual Mailing Lists wrote:

Quote:
I have situation where multiple databases need to use data from a common
source and it would consume way too much disk space to reproduce this
data into the many databases which require it. Is there some way to do a
join between databases or some other way of making the data in one
database available in another in a space-efficient manner? Of course it
is necessary that if this is possible any queries need to take advantage
of indexes/etc.
You could use dblink but it might not provide all the functionality
you're looking for. Could the multiple databases possibly be converted
into multiple schemas in the same database?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



Reply With Quote
  #3  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: Join between databases or (???) - 11-20-2004 , 11:31 PM



On Sat, Nov 20, 2004 at 07:37:12PM -0700, Net Virtual Mailing Lists wrote:

Quote:
If I want to take an existing table and add it into a schema is it
basically "alter database [database] rename [table] to schema.[table]"?....
Unfortunately not. See a recent thread in pgsql-sql that discussed
this:

http://archives.postgresql.org/pgsql...1/msg00139.php

Quote:
.. I guess that I was just looking for confirmation there was not
something in postgres which would allow this "full featured cross-
database join" before pulling an a few all nighters...
PostgreSQL doesn't have any inherent cross-database capabilities.
You can use dblink to query another database and join the results
against the current database, but its capabilities probably aren't
what you'd consider "full-featured." Still, you might want to
check it out if you're not familiar with it.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org



Reply With Quote
  #4  
Old   
Net Virtual Mailing Lists
 
Posts: n/a

Default Re: Join between databases or (???) - 11-21-2004 , 01:27 AM



Thanks for all your help Michael!

I am having one problem I just can't figure out.... In my dump file I
have something like:
CREATE SEQUENCE testschema.industries_industry_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
);

CREATE TABLE testschema.industries (
industry_id integer DEFAULT nextv
al('"testschema.industries_industry_id_seq"'::text ) NOT NULL,
industry character varying(80) NOT NULL,
entered_dt timestamp with time zone,
updated_dt timestamp with time zone
);


When I try to insert a value into schema.industries it complains about
testschema.industries_industry_id_seq not existing, yet I can execute
"nextval" against that very schema.... Any idea what might be going
wrong here?...

Thanks!

- Greg


Quote:
On Sat, Nov 20, 2004 at 07:37:12PM -0700, Net Virtual Mailing Lists wrote:

If I want to take an existing table and add it into a schema is it
basically "alter database [database] rename [table] to schema.[table]"?....

Unfortunately not. See a recent thread in pgsql-sql that discussed
this:

http://archives.postgresql.org/pgsql...1/msg00139.php

.. I guess that I was just looking for confirmation there was not
something in postgres which would allow this "full featured cross-
database join" before pulling an a few all nighters...

PostgreSQL doesn't have any inherent cross-database capabilities.
You can use dblink to query another database and join the results
against the current database, but its capabilities probably aren't
what you'd consider "full-featured." Still, you might want to
check it out if you're not familiar with it.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/



---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
  #5  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: Join between databases or (???) - 11-21-2004 , 10:15 AM



On Sun, Nov 21, 2004 at 12:27:11AM -0700, Net Virtual Mailing Lists wrote:

Quote:
I am having one problem I just can't figure out.... In my dump file I
have something like:
CREATE SEQUENCE testschema.industries_industry_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
);
The closing parenthesis is a syntax error. Did you cut and paste
this or type it by hand?

Quote:
CREATE TABLE testschema.industries (
industry_id integer DEFAULT nextv
al('"testschema.industries_industry_id_seq"'::text ) NOT NULL,
industry character varying(80) NOT NULL,
entered_dt timestamp with time zone,
updated_dt timestamp with time zone
);

When I try to insert a value into schema.industries it complains about
testschema.industries_industry_id_seq not existing, yet I can execute
"nextval" against that very schema.... Any idea what might be going
wrong here?...
I think you mean that you can execute nextval() against the sequence,
not the schema. Anyway, it looks like whatever created the dump
file incorrectly added double quotes around the sequence name in
the nextval() expression. What created that dump?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
  #6  
Old   
Net Virtual Mailing Lists
 
Posts: n/a

Default Re: Join between databases or (???) - 11-21-2004 , 03:06 PM



See comments below..

Quote:
On Sun, Nov 21, 2004 at 12:27:11AM -0700, Net Virtual Mailing Lists wrote:

I am having one problem I just can't figure out.... In my dump file I
have something like:
CREATE SEQUENCE testschema.industries_industry_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
);

The closing parenthesis is a syntax error. Did you cut and paste
this or type it by hand?

Yeha, sorry, I cut and pasted but fumbled.. The ); is not there - the
sequence did get created correctly...

Quote:
CREATE TABLE testschema.industries (
industry_id integer DEFAULT nextv
al('"testschema.industries_industry_id_seq"'::text ) NOT NULL,
industry character varying(80) NOT NULL,
entered_dt timestamp with time zone,
updated_dt timestamp with time zone
);

When I try to insert a value into schema.industries it complains about
testschema.industries_industry_id_seq not existing, yet I can execute
"nextval" against that very schema.... Any idea what might be going
wrong here?...

I think you mean that you can execute nextval() against the sequence,
not the schema. Anyway, it looks like whatever created the dump
file incorrectly added double quotes around the sequence name in
the nextval() expression. What created that dump?

pg_dump created it with the double quotes, I have been modifying the dump
to make it so appropriate things get created inside the schema, so I
added in the testschema. part of it in this example.

- Greg

Quote:
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
  #7  
Old   
gnari
 
Posts: n/a

Default Re: Join between databases or (???) - 11-21-2004 , 05:14 PM



From: "Net Virtual Mailing Lists" <mailinglists (AT) net-virtual (DOT) com>


Quote:
See comments below..


CREATE TABLE testschema.industries (
industry_id integer DEFAULT nextv
al('"testschema.industries_industry_id_seq"'::text ) NOT NULL,
[...]

When I try to insert a value into schema.industries it complains about
testschema.industries_industry_id_seq not existing, yet I can execute
"nextval" against that very schema.... Any idea what might be going
wrong here?...


pg_dump created it with the double quotes, I have been modifying the dump
to make it so appropriate things get created inside the schema, so I
added in the testschema. part of it in this example.
if you put the schema name inside the double quotes, it gets interpreted
as part of the relation name.
try DEFAULT nextval('testschema."industries_industry_id_seq"': :text)
or DEFAULT nextval('"testschema"."industries_industry_id_seq" '::text)
or DEFAULT nextval('testschema.industries_industry_id_seq'::t ext)

gnari



---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
  #8  
Old   
Tom Lane
 
Posts: n/a

Default Re: Join between databases or (???) - 11-21-2004 , 05:18 PM



"Net Virtual Mailing Lists" <mailinglists (AT) net-virtual (DOT) com> writes:
Quote:
CREATE TABLE testschema.industries (
industry_id integer DEFAULT nextval('"testschema.industries_industry_id_seq"': :text) NOT NULL,

pg_dump created it with the double quotes, I have been modifying the dump
to make it so appropriate things get created inside the schema, so I
added in the testschema. part of it in this example.
Ah-hah. You put the testschema. part in the wrong place then. Correct
is
nextval('"testschema"."industries_industry_id_seq" '::text)
Or you could leave out the double quotes.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



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.