Oracle uses one table field to update another table field.

Source: Internet
Author: User

1. update (select...) set column1 = column2;

Update (select iy. company_name company_name1, cc. company_name_jc company_name2
From income_year_item iy, city_company cc
Where iy. company_code = cc. code
)
Set company_name1 = company_name2;

2. Only one row of subquery s is allowed

Update CITY_PROJECT_SCALE_INFO c set
(C. value) = (
Select d. value from CITY_PROJECT_SCALE_INFO @ test d where d. project_id = '7d7fd580a06240b2a9137dc2bbe831e9'
And d. project_id = c. project_id and c. company_code = d. company_code
)
Where exists (
Select 1 from CITY_PROJECT_SCALE_INFO @ test d where d. project_id = '7d7fd580a06240b2a9137dc2bbe831e9'
And d. project_id = c. project_id and c. company_code = d. company_code
)

3. Use the merg inot statement

-- Update basic production fields
Merge into city_cfg_data_column_common cf1 using
City_cfg_data_column_common2 cf2 on
(Cf1.resourceid = cf2.resourceid)
When matched then
Update set cf1.template _ type = cf2.template _ type,
Cf1.chinese _ name = cf2.chinese _ name,
Cf1.column _ name = cf2.column _ name,
Cf1.column _ type = cf2.column _ type,
Cf1.column _ size = cf2.column _ size
When not matched then
Insert (cf1.resourceid, cf1.template _ type, cf1.chinese _ name, cf1.column _ name, cf1.column _ type, cf1.column _ size
, Cf1.is _ can_edit, cf1.is _ unique, cf1.is _ can_cover, cf1.show _ order)
Values (cf2.resourceid, cf2.template _ type, cf2.chinese _ name, cf2.column _ name, cf2.column _ type, cf2.column _ size
, Cf2.is _ can_edit, cf2.is _ unique, cf2.is _ can_cover, cf2.show _ order)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.