Redshift - Cross-database reference insert - Is it possible?

839 Views Asked by At

I have a question about cross database referencing in a Redshift cluster that we are doing a POC on. The basic question is, is it possible to do an insert from a connection on one database in the cluster, to a table in a different database/schema in the same cluster?

There are 2 databases

  1. db_1
  2. db_2

Both databases (and all objects (schemas/tables) inside) are owned by the user test_batch_user

Our use case is that we have ETL jobs which will write to multiple tables across multiple databases in the cluster.

To run the job, the connection will be made using the test_batch_user user on the db_1 database.

The table we wish to insert into is db_2.dims.dim_dates. When connected as the test_batch_user user on the db_1 database, I can do a SELECT * FROM db_2.dims.dim_dates; and get the expected result.

However when I try to do an insert to this table using the same connection, I get the following error [0A000] ERROR: cross-database reference to database "db_2" is not supported

INSERT INTO db_2.dims.dim_dates
(
 IDDATE
)
SELECT current_date;

In general is what we are trying to achieve possible?

0

There are 0 best solutions below