Re: [SQL] Comparing two tables of different database

2009-05-02 Thread Isaac Dover
Thank you, Lucas. I'm from the MS world, still learning these PG things. Though, it appears that the difference is somewhat minor. In my actual implementation, [other database] would be a linked server, which sounds like it would be similar to the PG dblink. Regardless, I've found information schem

Re: [SQL] using a list to query

2009-05-02 Thread Craig Ringer
johnf wrote: > I have a list (or array) of primary keys stored in a field (data type text). > I would like to use the list to retrieve all the data from a table based on > the list. > > my text field contains: > '123,134,343,345' > > I would to do something like the following: > > Select * f

Re: [SQL] Comparing two tables of different database

2009-05-02 Thread Lucas Brito
2009/5/2 Isaac Dover > i've not tried this in postgres, but using information_schema makes > comparing structures of databases trivial. i've been using this query for a > while with MSSQL. Maybe this helps to answer the question. > > - isaac > > select ST.Table_Name, ST.Column_Name, DV.Table_Name

Fwd: [SQL] Comparing two tables of different database

2009-05-02 Thread Isaac Dover
i've not tried this in postgres, but using information_schema makes comparing structures of databases trivial. i've been using this query for a while with MSSQL. Maybe this helps to answer the question. - isaac select ST.Table_Name, ST.Column_Name, DV.Table_Name, DV.Column_Name, * from [database

[SQL] using a list to query

2009-05-02 Thread johnf
I have a list (or array) of primary keys stored in a field (data type text). I would like to use the list to retrieve all the data from a table based on the list. my text field contains: '123,134,343,345' I would to do something like the following: Select * from table1 where table1.pkid in (

Re: [SQL] Comparing two tables of different database

2009-05-02 Thread Lucas Brito
Nicholas, To use the dblink: 1. In your postgres server you should find a file *dblink.sql*. In my beta installation is in *share/postgresql/contrib*. It is the installation for the dblink contrib module that usually is already compiled in. It will create a lot of dblink functions.

Re: [SQL] Comparing two tables of different database

2009-05-02 Thread M.P.Dankoor
In case dblink was not installed, you could try the following: 1. dump only the data from the table from database 1 pg_dump -U username -a -d -t tablename dbname > tablename.sql 2. create a (temp) table in database 2 SELECT * INTO tablename_bak from tablename WHERE 1 = 2 3. restore the dumped d