oracle常規操作

2021-07-25 08:00:26 字數 1892 閱讀 4729

1、建立表

sql**  

create

table test(  

id varchar2(10),  

age number  

);  

2、備份表

sql**  

create

table

asselect * from test group

by id;  

3、刪除表

sql**  

drop

table test;--刪除表結構和表資料

4、清空表

sql**  

truncate

table test;--清空資料表資料,沒有返回餘地

delete

from test;---清空資料表資料,有返回餘地

sql**  

alter

table test add (  

name varchar2(10),  

interest varchar2(20)  

);  

6、刪除字段

sql**  

alter

table test drop

name;  

7、更新資料

7.1更新一條資料

sql**  

update test t   

set t.id='001'

where t.id is

notnull;  

commit;  

7.2從其他表更新多條資料

sql**  

update test t set t.name=(  

select tm.name

from test_common tm   

where t.id=tm.id  

);  

commit;  

--備註:update資料時,最好將update子查詢中的sql單獨建表,提高更新速度。

sql**  

select * from test for

update;  

--備註:更新操作執行完,要鎖上資料表,同時執行commit提交操作

8、查詢資料

sql**  

select * from test;  

9、查詢資料表數量

sql**  

select

count(0) from test;  

--備註:count(0)或者其他數字比count(*)更加節省資料庫資源,高效快捷

10、插入資料

10.1插入一條資料中的多個字段

sql**  

insert

into test (c1,c2) values(1,'技術部');  

sql**  

insert

into test(c1,c2) select c1,c2 from test_common;  

commit;  

sql**  

insert

into test(  

id,  

name,  

age  

)  select

id,  

name,  

age  

from test_common;  

commit;  

--備註:1、插入多條資料時,insert into語句後面沒有values,直接拼接資料查詢語句;2、在oracle中對資料表進行了insert、update、delete等操作後,要執行commit提交,否則在系統處是禁止運算元據庫的,因為此時資料庫已經被鎖死,這是資料庫為了防止多人同時修改資料庫資料造成混亂的一種防範機制。

Oracle 常規ArcSDE操作

arcsde需要安裝oracle64位伺服器端,32位客戶端。使用plsql也需要32位客戶端,要不然登入不上!使用者名稱 sys 密碼 12345678 使用者名稱 scott 密碼 tiger 問題 exp與expdb區別?在10之前,傳統的匯出和匯入分別使用exp工具和imp工具,從10開始,...

Oracle使用中的常規操作總結

寫一篇在使用oracle過程中一些常用的操作,以便於忘記的時候檢視 一.建立使用者和給使用者賦予許可權 create user 使用者名稱 identified by 密碼 12c一下版本 create user c 使用者名稱 identified by 密碼 12c以上版本需要加上c 但建立出來...

oracle常規用法

顯示資料庫名 show parameterdb name 查詢併發數 select count from v session where status active username,osuser from v session sql id from v session where osuser l...