Oracle Updates another table field with one table field three ways ____oracle

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 single-line subquery s

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 Merg inot statement

--Update Production base 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)

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.