当前位置:网站首页>Oracle updates the data of different table structures and fields to another table, and then inserts it into the new table
Oracle updates the data of different table structures and fields to another table, and then inserts it into the new table
2022-04-23 21:25:00 【Plant a sweet smell】
Oracle Update and insert operations of different tables
In production , A table due to configuration problems A There is no data in one of the fields , Result in B The data in the table is completely null.
The current requirements are as follows : With the help of g_wo_sn C The data of serial_number, Then update the data to G_SN_IMEI_MANAGE A Tabular SN Column , The structure of the two tables is inconsistent , Then insert into C surface
namely : hold C Of serial_number Update to A Tabular SN
C The table structure is as follows
select a.*,rownum from g_wo_sn a where A.WORK_ORDER='WORK015903' and rownum<=9000;

B The table structure is as follows
select a.*,rownum from G_SN_IMEI_MANAGE a where a.WORK_ORDER='WORK015903' and rownum<=9000;

because C Table and A The table structure of the table is different , There is no same row data . But watch carefully A Table fields , We found that A Tabular NOT_BURN_IMEI This column has no data ,name You can use Oracle Built in functions for rownum Update data . Steps are as follows :
1. Update first A Tabular NOT_BURN_IMEI Field , Let it be arranged in numbers . namely NOT_BURN_IMEI=rownum. This is the most important step
update G_SN_IMEI_MANAGE set NOT_BURN_IMEI=rownum where WORK_ORDER='WORK015903';
2. After the C Tabular serial_number Update to A Tabular SN in
update G_SN_IMEI_MANAGE a set a.sn=(select t.serial_number from (select a.*,rownum as g from g_wo_sn a where A.WORK_ORDER='WORK015903' and rownum<=9000)t where t.g=a.NOT_BURN_IMEI) where a.work_order='WORK015903';

3. The last update A Tabular NOT_BURN_IMEI Field
update G_SN_IMEI_MANAGE set NOT_BURN_IMEI=null where WORK_ORDER='WORK015903';
4. Then insert into B In the table
insert into IMEI_SN_K1807 b (WORK_ORDER,PART_ID,SN,IMEI,UPDATE_USERID,UPDATE_TIME,FLAG)
(select WORK_ORDER,PART_ID,SN,IMEI,OPERATOR_ID,OPERATOR_TIME,FLG from G_SN_IMEI_MANAGE a where a.WORK_ORDER='WORK015903') ;
Of course , We can also use Excle File import . But when it comes to different data volumes of two tables , You can try rownum function , It's much easier to use than you think .
版权声明
本文为[Plant a sweet smell]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/110/202204200619557482.html
边栏推荐
- [※ leetcode refers to offer 46. Translate numbers into strings (medium)]
- How Axure installs a catalog
- How to learn software testing? Self study or training? After reading this article, you will understand
- On the three paradigms of database design
- The more you use the computer, the slower it will be? Recovery method of file accidental deletion
- South Korea may ban apple and Google from offering commission to developers, the first in the world
- 管道和xargs
- Ubuntu 20 installing centernet
- unity 功能扩展
- Sequential state
猜你喜欢

Keywords static, extern + global and local variables

Pipes and xargs

Question brushing plan -- backtracking method (I)

How Axure installs a catalog

DeNO 1.13.2 release

小米手机全球已舍弃“MI”品牌,全面改用“xiaomi”全称品牌

Minecraft 1.12.2模组开发(四十三) 自定义盾牌(Shield)

Recommended usage scenarios and production tools for common 60 types of charts

Pycharm Chinese plug-in

wait、waitpid
随机推荐
[※ leetcode refers to offer 46. Translate numbers into strings (medium)]
unity 功能扩展
Keywords static, extern + global and local variables
Graph traversal - BFS, DFS
Gsi-ecm digital platform for engineering construction management
Write table of MySQL Foundation (create table)
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ‘:app:stripDe
[leetcode refers to offer 22. The penultimate node in the linked list (simple)]
setInterval、setTimeout、requestAnimationFrame
Leetcode-279-complete square number
[leetcode refers to offer 10 - I. Fibonacci sequence (simple)]
Sharpness difference (SD) calculation method of image reconstruction and generation domain index
How to use the project that created SVN for the first time
Detailed explanation of basic assembly instructions of x86 architecture
[leetcode sword finger offer 10 - II. Frog jumping steps (simple)]
Keras. Layers introduction to various layers
Plato Farm元宇宙IEO上线四大,链上交易颇高
Flomo software recommendation
Is rust more suitable for less experienced programmers?
[leetcode refers to offer 42. Maximum sum of continuous subarrays (simple)]