ORACLE__UPDATE_语句

ORACLE__UPDATE_语句

ID:44890268

大小:34.00 KB

页数:5页

时间:2019-11-01

ORACLE__UPDATE_语句_第1页
ORACLE__UPDATE_语句_第2页
ORACLE__UPDATE_语句_第3页
ORACLE__UPDATE_语句_第4页
ORACLE__UPDATE_语句_第5页
资源描述:

《ORACLE__UPDATE_语句》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、ORACLE_UPDATE语句Update语句Update语句用于修改表中的数据。语法:UPDATE表名称SET列名称=新值WHERE列名称=某值为了方便起见,建立了以下简单模型,和构造了部分测试数据:  在某个业务受理子系统BSS中,  --客户资料表  createtablecustomers  (  customer_id  number(8)    notnull,  --客户标示  city_name    varchar2(10)notnull,  --所在城市  customer_typechar(2)      notnull

2、,  --客户类型  ...  )  createuniqueindexPK_customersoncustomers(customer_id)  由于某些原因,客户所在城市这个信息并不什么准确,但是在  客户服务部的CRM子系统中,通过主动服务获取了部分客户20%的所在  城市等准确信息,于是你将该部分信息提取至一张临时表中:  createtabletmp_cust_city  (  customer_id    number(8)notnull,  citye_name    varchar2(10)notnull,  customer

3、_type  char(2)  notnull  )1)最简单的形式  --经确认customers表中所有customer_id小于1000均为'北京'  --1000以内的均是公司走向全国之前的本城市的老客户:)  updatecustomers  set    city_name='北京'  where  customer_id<10002)两表(多表)关联update--仅在where字句中的连接  --这次提取的数据都是VIP,且包括新增的,所以顺便更新客户类别  updatecustomers  a      --使用别名  se

4、t    customer_type='01'--01为vip,00为普通  where  exists(select1                  from  tmp_cust_cityb                  where  b.customer_id=a.customer_id                )3)两表(多表)关联update--被修改值由另一个表运算而来  updatecustomersa  --使用别名  setcity_name=(selectb.city_namefromtmp_cust_city

5、bwhereb.customer_id=a.customer_id)  where  exists(select1                  from  tmp_cust_cityb                  where  b.customer_id=a.customer_id                )  --update超过2个值  updatecustomersa  --使用别名  set    (city_name,customer_type)=(selectb.city_name,b.customer_type

6、                                    from  tmp_cust_cityb                                    where  b.customer_id=a.customer_id)  where  exists(select1                  from  tmp_cust_cityb                  where  b.customer_id=a.customer_id                )  注意在这个语句中,      

7、                            =(selectb.city_name,b.customer_type                                    from  tmp_cust_cityb                                    where  b.customer_id=a.customer_id                                    )  与                (select1                  fro

8、m  tmp_cust_cityb                  where  b.customer_id=a.customer_id             

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。