How to combine select and update query in sql
- select and update in one query oracle
- select and insert in one query oracle
- update using select in oracle
- what is select for update in oracle
Oracle update from select join
Oracle update with select subquery.
Updates Based on Queries
Home » Articles » Misc » Here
This article describes how a table can be updated using data from another table.
Related articles.
Setup
The table contains 10,000 rows.
The table contains 5,000 rows, each of which has a matching key value with a row from the table, but different data in the and columns.
DROP TABLE dest_tab PURGE; DROP TABLE source_tab PURGE; CREATE TABLE dest_tab AS SELECT level AS id, 'CODE' || level AS code, 'Description for ' || level AS description FROM dual CONNECT BY level <= 10000; ALTER TABLE dest_tab ADD CONSTRAINT dest_tab_pk PRIMARY KEY (id); CREATE TABLE source_tab AS SELECT level AS id, 'CODE' || (level*10) AS code, 'Updated description for ' || level AS description FROM dual CONNECT BY level <= 5000; ALTER TABLE source_tab ADD CONSTRAINT source_tab_pk PRIMARY KEY (id); EXEC DBMS_STATS.gather_table_stats(USER, 'dest_tab'); EXEC DBMS_STATS.gather_table_stats(USER, 'source_tab');At this point we can see none of the values in the column of the table contain the word "Updated".
SELECT COUNT(*) FROM des- oracle select for update example
- select and update in same query oracle