Not using a built in command, but...
If an UPDATE
really can satisfy your requirements as your title implies, then no inserts should be necessary and the primary key must be in sync between the databases.
Your requirements don't allow remote updates, but if you can remotely query the database, then you can join the local table to the remote table to create the statements that will need to be run the remote system. Here is a demonstration:
drop table t1;
drop table t2;
create table t1 as (select level c1, level c2 from dual connect by level <=7);
create table t2 as (select * from t1);
update t2 set c2 = null where c1 in (3,6);
select * from t1;
select * from t2;
select 'UPDATE t2 SET c2 = ' || t1.c2 || ' WHERE c1=' || t1.c1 || ';' sql from t1
join t2 on t1.c1 = t2.c1
where t1.c2 <> t2.c2 OR t2.c2 is null;
If you cannot query the remote database, you can update every row like this:
drop table t1;
create table t1 as (select level c1, level c2 from dual connect by level <=7);
select 'UPDATE t2 SET c2 = ' || t1.c2 || ' WHERE c1=' || t1.c1 || ';' sql from t1;
A DATA_LENGTH
of 22 is just the largest number of bytes it can take to store the largest possible number (Oracle uses 2 digits per byte). A NULL
DATA_PRECISION
implies the maximum of 38.
You can verify this with DBMS_METADATA
:
SQL> create table sotmp ( a int );
Table created.
SQL> select dbms_metadata.get_ddl('TABLE','SOTMP')
2 from dual;
DBMS_METADATA.GET_DDL('TABLE','SOTMP')
--------------------------------------------------------------------------------
CREATE TABLE "PHIL"."SOTMP"
( "A" NUMBER(*,0)
) SEGMENT CREATION DEFER
SQL>
(The "*" in the above output denotes the maximum precision).
BINARY_INTEGER
is not a data type that can be used in table columns. It can only be used as a PL/SQL variable datatype.
Best Answer
Set up environment:
Find my SQL and the captured bind values:
Problem: the value of
:B2
was not captured because it is not part of aWHERE
/HAVING
clause.Enable SQL tracing in my session for this specific SQL statement and find the trace file:
Run the SQL again:
And the content of the trace file:
:B2
is the first bind variable in the SQL text, so it is labelled asBind 0
, and you can see the actual value asvalue=2
.You can set the above systemwide (
alter system
instead ofalter session
), but each server process will have a seperate trace file and you will need to collect the required information from them.