473,387 Members | 1,542 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,387 software developers and data experts.

how to merge a table from another DB

I have a bit of a dilemma, I'm fairly new to PG, and not quite sure how
to do this:
I have a DB that has been basically 'forked' - a copy of the original
was made for a handful of users to play with without messing with the
live DB. Now, they would like to know if the changes they have made to
the forked db can be merged back in to the live one. A change to one
column of every row in a certain table. How can I update just that field
in every row of the db without harming the existing data already in that
table?

thanks in advance.

-Todd

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 22 '05 #1
4 2440
> the forked db can be merged back in to the live one. A change to one
column of every row in a certain table. How can I update just that field
in every row of the db without harming the existing data already in that
table?


Would something like this work?

UPDATE table1
set table1.columna = table2.columna
from table2
where table1.keyfield = table2.keyfield;
--
Mike Nolan

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

Nov 22 '05 #2
On Tue, Feb 17, 2004 at 11:55:55 -0700,
"Hought, Todd" <To*********@echostar.com> wrote:
I have a bit of a dilemma, I'm fairly new to PG, and not quite sure how
to do this:
I have a DB that has been basically 'forked' - a copy of the original
was made for a handful of users to play with without messing with the
live DB. Now, they would like to know if the changes they have made to
the forked db can be merged back in to the live one. A change to one
column of every row in a certain table. How can I update just that field
in every row of the db without harming the existing data already in that
table?


To change the data in a column you can just use an update command.
Alter table can be used to change constraints or to change the column
tpye. (The latter is usually done by adding a new column, converting
the old values, dropping the old column, renaming the new column
back to the original name, and then fixing any constraints.)

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

Nov 22 '05 #3
On Tue, 17 Feb 2004, Hought, Todd wrote:
I have a bit of a dilemma, I'm fairly new to PG, and not quite sure how
to do this:
I have a DB that has been basically 'forked' - a copy of the original
was made for a handful of users to play with without messing with the
live DB. Now, they would like to know if the changes they have made to
the forked db can be merged back in to the live one. A change to one
column of every row in a certain table. How can I update just that field
in every row of the db without harming the existing data already in that
table?


If you're running 7.3 or above, look at merging the two databases under
one with different schemes and permissions. then you'd be able to do
updates pretty easily. Otherwise, you're gonna have to export / import
your data from one machine to the other with pg_dump / psql or pg_restore
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 22 '05 #4
Could you do...

UPDATE mytable SET mycolumn =
(
SELECT myothercolumn
FROM myothertable
WHERE myothertable.primarykey = mytable.primarykey
)

Not sure how this works in PostgreSQL, but I do it all the time in
Oracle (note only one table definition in subselect)
thanks!

~ Troy Campano ~

On Tue, 2004-02-17 at 13:55, Hought, Todd wrote:
I have a bit of a dilemma, I'm fairly new to PG, and not quite sure how
to do this:
I have a DB that has been basically 'forked' - a copy of the original
was made for a handful of users to play with without messing with the
live DB. Now, they would like to know if the changes they have made to
the forked db can be merged back in to the live one. A change to one
column of every row in a certain table. How can I update just that field
in every row of the db without harming the existing data already in that
table?

thanks in advance.

-Todd

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

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

Nov 22 '05 #5

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

Similar topics

0
by: Pierre-Luc Soucy | last post by:
Hi, I was working on some merge tables this morning and it worked fine, but after a few unsuccessful table creation requests (I was making some tests), I could not alter or select from a table...
8
by: Nils | last post by:
Hello, my problem: I merged about 1.000 Tables with Create table name (variables) type=merge union=(table1,table2,...,table1000); MySQL now creates a tables, but I can't open it....
3
by: jaykchan | last post by:
One of the table that is in a merge replication somehow is missing an index. Strangely, only the table in one of the subscriber of the merge replication is missing the index; another subscriber and...
2
by: Private Pyle | last post by:
AIX 5.1, DB2 8.1.3 64-bit ESE 5 partitions 1 catalog, 4 data. I have a situation where I have to update 269,000,000 rows in a table with the value in another table with just about the same number...
0
by: Shiraz | last post by:
Hi I have a question regarding the functionality of merge modules. Since this relates to my previous queries, I'll just give you a brief background on the topic. I had to make an installer for...
0
by: Brett Romero | last post by:
If I have a dataset with one table and want to merge another table, how does merge know which column to match rows on in each table? For example Table 1: personid firstname lastname address
8
by: Ron B | last post by:
Help!!! What am I doing wrong? I am working with Office 2003 and am trying to create a command button on an Access form that will create a mail merge in Word from an Access table. I want to...
6
by: amitabh.mehra | last post by:
I want to trap errors (RI errors), if any, that might turn up during merge in DB2. Is there some feature like the one in Oracle: MERGE INTO... WHEN MATCHED THEN UPDATE... WHEN NOT MATCHED THEN...
7
by: Michel Esber | last post by:
Question About Merge DB2 V8 LUW FP 15. Hello, Consider table A (ID integer not null PK, Field2 varchar(50)). I have the existing following set of rows in the table:
24
by: Henry J. | last post by:
My app needs to insert thousand value rows into a mostly empty table (data are read from a file). I can either use inserts, or use merge. The advantage of using merge is that in the few cases...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.