oracle 常用語句彙總

2022-06-26 15:39:13 字數 1359 閱讀 5419

一.複製表資料至另一張表

直接建相同的表並將資料複製過去:

create table students_backup as select * from students;

只建相同的表結構:

create table students_backup as select * from students where 1=2;

表已建好,直接複製資料:

insert into students_backup select * from students

二.兩表(多表)關聯update

1.僅在where子句中的連線

sql **

--

這次提取的資料都是vip,且包括新增的,所以順便更新客戶類別

update customers a --

使用別名

set customer_type='01

'--01 為vip,00為普通

where

exists (select

1from

tmp_cust_city b

where b.customer_id=

a.customer_id

)

2. 被修改值由另乙個表運算而來

sql **

update customers a --

使用別名

set city_name=(select b.city_name from tmp_cust_city b where b.customer_id=

a.customer_id)

where

exists (select

1from

tmp_cust_city b

where b.customer_id=

a.customer_id)--

update 超過2個值

update customers a --

使用別名

set (city_name,customer_type)=(select

b.city_name,b.customer_type

from

tmp_cust_city b

where b.customer_id=

a.customer_id)

where

exists (select

1from

tmp_cust_city b

where b.customer_id=

a.customer_id

)

oracle 常用語句

oracle 產看表空間 select total.name tablespace name free space,total space free space used space,total space from select tablespace name,sum bytes 1024 102...

oracle常用語句

drop tablespace crm online space including contents and datafiles 刪除表空間 drop user wuliu01 cascade 刪除使用者 exp orcl file d dmp 匯出資料庫 imp orcl file e alen...

oracle 常用語句

oracle 常用語句 查詢表的大小 select t.owner,t.segment name,sum t.blocks 8 1024 m as s,t.segment type from dba segments t where t.owner user name group by t.owne...