Skip to content

Instantly share code, notes, and snippets.

@ruan4261
Last active October 14, 2021 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruan4261/810d8d336537379eda0190d4ec3e6329 to your computer and use it in GitHub Desktop.
Save ruan4261/810d8d336537379eda0190d4ec3e6329 to your computer and use it in GitHub Desktop.
-- Replace ${} with your text
-- Compare the structure of two tables
-- Pay attention to the case of the table name
select v1.table_name,v2.table_name, v1.column_name,v2.column_name,
v1.data_type,v2.data_type,v1.data_length,v2.data_length ,v1.data_precision,v2.data_precision,v1.data_scale,v2.data_scale
from
(select * from user_tab_columns where table_name='${table_A}') v1 left join
(select * from user_tab_columns where table_name='${table_B}') v2 on v1.column_name=v2.column_name
-- Query from historical data
SELECT columns FROM ${table} AS OF TIMESTAMP TO_TIMESTAMP('rollback time','${YYYY-MM-DD HH24:MI:SS}')
-- Join table update
update ${table_A} a set
${field} = (select b.${field} from ${table_B} b where b.${field} = a.${field})
where ${field} = ${target}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment