自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Oracle多表關(guān)聯(lián)中的update語(yǔ)句實(shí)際應(yīng)用

數(shù)據(jù)庫(kù) Oracle
我們今天主要和大家討論的是 Oracle多表關(guān)聯(lián)中的update語(yǔ)句的實(shí)際應(yīng)用,本文主要是以代碼的方式來(lái)引出Oracle多表關(guān)聯(lián)中的update語(yǔ)句的實(shí)際操作。

以下的文章主要講述的是 Oracle多表關(guān)聯(lián)中的update語(yǔ)句的實(shí)際應(yīng)用,為了使大家更為仔細(xì)的看明白其實(shí)際的操作步驟,我們建立了下面的簡(jiǎn)單模型與構(gòu)造一部分的測(cè)試數(shù)據(jù):在某個(gè)業(yè)務(wù)受理子系統(tǒng)BSS中,

客戶資料表

 

  1. create table customers  
  2. (  
  3. customer_id number(8) not null,   

 

客戶標(biāo)示

  1. city_name varchar2(10) not null, 

所在城市

  1. customer_type char(2) not null, 

客戶類型

 

  1. ...  
  2. )  
  3. create unique index PK_customers on customers (customer_id)  

 

由于某些原因,客戶所在城市這個(gè)信息并不什么準(zhǔn)確,但是在

客戶服務(wù)部的CRM子系統(tǒng)中,通過(guò)主動(dòng)服務(wù)獲取了部分客戶20%的所在

城市等準(zhǔn)確信息,于是你將該部分信息提取至一張臨時(shí)表中:

 

  1. create table tmp_cust_city  
  2. (  
  3. customer_id number(8) not null,  
  4. citye_name varchar2(10) not null,  
  5. customer_type char(2) not null  
  6. )  

 

1) 最簡(jiǎn)單的形式

經(jīng)確認(rèn)customers表中所有customer_id小于1000均為'北京'

1000以內(nèi)的均是公司走向全國(guó)之前的本城市的老客戶:)

 

  1. update customers 

set city_name='北京'

 

  1. where customer_id<1000 

2) 兩表(多表)關(guān)聯(lián)Oracle update 僅在where字句中的連接

這次提取的數(shù)據(jù)都是VIP,且包括新增的,所以順便更新客戶類別

 

  1. update customers a  

使用別名

 

  1. set customer_type='01'  

01 為vip,00為普通

 

  1. where exists (select 1  
  2. from tmp_cust_city b  
  3. where b.customer_id=a.customer_id  
  4. )  

 

3) Oracle 兩表(多表)關(guān)聯(lián)update 被修改值由另一個(gè)表運(yùn)算而來(lái)

 

  1. update customers a  

使用別名

 

  1. set city_name=(select b.city_name from tmp_cust_city b where b.customer_id=a.customer_id)  
  2. where exists (select 1  
  3. from tmp_cust_city b  
  4. where b.customer_id=a.customer_id  
  5. )   

 

上述的相關(guān)內(nèi)容就是對(duì) Oracle多表關(guān)聯(lián)的update語(yǔ)句的描述,希望會(huì)給你帶來(lái)一些幫助在此方面。

【編輯推薦】

  1. Oracle case的2中常用表達(dá)式
  2. Oracle表空間的設(shè)置問(wèn)題的描述
  3. Oracle數(shù)據(jù)字典的恢復(fù)場(chǎng)景
  4. Oracle EXPLAIN PLAN的實(shí)際應(yīng)用經(jīng)驗(yàn)總結(jié)
  5. 修改Oracle默認(rèn)用戶密碼有效期時(shí)間的實(shí)操
責(zé)任編輯:佚名 來(lái)源: 博客園
相關(guān)推薦

2010-05-04 15:15:39

Oracle分頁(yè)查詢

2010-09-17 10:39:36

SQL中

2010-09-27 10:29:14

sql update語(yǔ)

2010-05-10 18:38:08

Oracle分頁(yè)語(yǔ)句

2010-04-08 17:40:02

Oracle 多表關(guān)聯(lián)

2009-12-02 19:51:54

PHP Switch語(yǔ)

2010-03-30 14:32:38

Oracle Date

2010-04-08 18:33:46

Oracle VARR

2010-05-06 16:02:42

Oracle SQL

2010-03-29 11:06:22

Oracle Spat

2011-08-22 15:47:27

Oracle臨時(shí)表存儲(chǔ)過(guò)程

2010-04-29 09:16:16

Oracle密碼過(guò)期處

2010-04-09 09:28:30

Oracle自增字段

2010-04-21 13:31:11

Oracle時(shí)間

2010-03-29 15:33:18

Oracle EXP

2010-03-31 17:40:15

Oracle SELE

2010-04-06 16:00:19

Oracle更改表

2010-04-09 13:35:35

Oracle啟動(dòng)

2010-04-09 16:26:53

Oracle join

2010-04-28 15:04:37

Oracle數(shù)據(jù)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)