Parameter variable schema oracle

2019-06-09 05:55发布

问题:

I'm newbie using Oracle.

I have a question: in SQL Server, we can use:

DECLARE DBNAME1 VARCHAR(20)
DECLARE DBNAME2 VARCHAR(20)

SET @DBNAME1 ='TEST_DB'
SET @DBNAME2 ='TEST_DB2'

INSERT INTO @DBNAME1.TABLECORE
    SELECT * 
    FROM @DBNAME2.TABLENONCORE T

What is the equivalent of this script in if @DBNAME == Schema in Oracle?

回答1:

We can manage it but creating db link on dbname2 :

create public database link dbname2 connect to myschema using 'abc-scan.mycompany.com.tr:1521/dbname2.mycompany.com.tr';

and calling the following dml statement from dbname1 :

insert into tablecore select * from tablenocore@dbname2;