Is it possible to update a table in another Netezza database on same server?
Question
I am trying to update tables in a production environment from a staging environment. I wrote an update statement (simplified version below) that will use data from another database and I'm getting a "Cross Database Access not supported for this type of command" error. I can successfully insert data from another database, but not update. Maybe this is not allowed? In the below examples, I am logged into DB1.
First attempt:
UPDATE DB1..EMPLOYEE e1
SET e1.name = e2.name,
e1.phone = e2.phone
FROM DB2..EMPLOYEE e2
WHERE e1.id = e2.id;
2nd attempt:
UPDATE DB1..EMPLOYEE e1
SET e1.name = e2.name,
e1.phone = e2.phone
FROM (select name, phone, id from DB2..EMPLOYEE) e2
WHERE e1.id = e2.id;
Solution
You are correct, you can only change stuff in the database you're currently connected to.
Cross database statements reading from a different database in order to change data in the current database are supported though, so those statements should work while you're connected to DB1.
edit: the update statements above update a table in DB1, so you need to be connected to DB1.