oracle 常用處理表結構

2021-10-01 09:35:04 字數 1811 閱讀 1431

以下內容屬於個人經常使用總結記錄,如有不正確的地方請大家指出,會繼續完善

使用者管理:

--1、刪除使用者,並且清掉快取 使用者名稱=cuser1 

drop user cuser1  cascade 

--2、建立使用者,使用者名稱=cuser1,密碼=cuser123 

create user cuser1 identified by cuser123;

--3、設定許可權 dba  最大許可權

grant dba to cuser1

--授予部分 許可權

grant create session, create table, create view, create any index, create sequence, create type 

to cuser1; 

--4、匯出dmp檔案

exp cuser1 /cuser123 @10.1.1.15:1521/orcl tables=(t_users,t_dep)  file=e:/databak.dmp 

cuser1 =使用者名稱、cuser123 =密碼、10.1.1.15:1521/orcl=伺服器ip位址,file=檔案存放路徑,

tables=匯出的包含哪些表(可省該引數略)

--5、匯入dmp檔案

imp cuser1 /cuser123 @10.1.1.15:1521/orcl  file=e:/databak.dmp full=y ignore=y

cuser1 =使用者名稱、cuser123 =密碼、10.1.1.15:1521/orcl=伺服器ip位址,file=檔案存放路徑,full=全備份,ignore=忽略錯誤繼續

--6、查詢表名

select t.table_name||',',t.num_rows from user_tables t order by num_rows desc  

--7、檢視表空間 

select b.file_name as "物理檔名", 

b.tablespace_name as "表空間", 

b.bytes / 1024 / 1024 as "大小m", 

(b.bytes - sum(nvl(a.bytes, 0))) / 1024 / 1024 as "已使用m", 

substr((b.bytes - sum(nvl(a.bytes, 0))) / (b.bytes) * 100, 1, 5) as "利用率" 

from dba_free_space a, dba_data_files b 

where a.file_id = b.file_id 

group by b.tablespace_name, b.file_name, b.bytes 

order by b.tablespace_name; 

--8、獲取資料庫中有哪些賬戶

select * from dba_users order by username 

--9、查詢每個使用者占用的空間

select owner as "使用者名稱", sum(bytes) / 1024 / 1024 / 1024 as "所有表的大小(gb)"

from dba_segments

where segment_name in (select t2.object_name

from dba_objects t2

where t2.object_type = 'table')

group by owner order by 2 desc

imp exp 具體引數可以參考

以上內容屬於個人經常使用總結記錄,如有不正確的地方請大家指出,會繼續完善

Oracle建立和處理表

表 基本的資料儲存集合,由行和列組成。使用者定義的表 使用者自己建立並維護的一組表 包含了使用者所需的資訊 檢視使用者建立的表 select from user tables 資料字典 由oracle server 自動建立的一組表 包含資料庫資訊 檢視使用者定義的表 select table na...

ORACLE處理表鎖住了的辦法

oracle資料庫操作中,我們有時會用到鎖表查詢以及解鎖和kill程序等操作,那麼這些操作是怎麼實現的呢?本文我們主要就介紹一下這部分內容。1 鎖表查詢的 有以下的形式 select count from v locked object select from v locked object 2 檢...

時間常用處理

以下的毫秒都採用最大997,而不是999 因為sql server的精度為3毫秒 本月的天數 intdaysinmonth datetime.daysinmonth datetime.now.year,datetime.now.month 本年的天數 是否是閏年 intdaysinyear date...