-- 檢視表空間
select upper(f.tablespace_name) "表空間名",
d.tot_grootte_mb "表空間大小(m)",
d.tot_grootte_mb - f.total_bytes "已使用空間(m)",
to_char(round((d.tot_grootte_mb - f.total_bytes) / d.tot_grootte_mb * 100,
2),'990.99') "使用比%",
f.total_bytes "空閒空間(m)",
f.max_bytes "最大塊(m)"
from (select tablespace_name,
round(sum(bytes) / (1024 * 1024), 2) total_bytes,
round(max(bytes) / (1024 * 1024), 2) max_bytes
from sys.dba_free_space
group by tablespace_name) f,
(select dd.tablespace_name,
round(sum(dd.bytes) / (1024 * 1024), 2) tot_grootte_mb
from sys.dba_data_files dd
group by dd.tablespace_name) d
where d.tablespace_name = f.tablespace_name
order by f.tablespace_name;
-- 檢視表空間是否為自動擴充套件
select tablespace_name, autoextensible, increment_by from dba_data_files;
--如果你的系統表空間不是自動擴充套件的那麼,有如下方法可以進行擴充套件。
--1、增加system表空間的資料檔案。
alter tablespace system add datafile 'd:\oraclexe\oradata\xe\system_01.dbf' resize 1024m;
--2、更改system的資料檔案,讓其自動擴充套件,並擴大其大小。
alter database datafile 'd:\oraclexe\oradata\xe\system_01.dbf' autoextend on;
alter database datafile 'd:\oraclexe\oradata\xe\system_01.dbf' resize 2048m;
-- 增加表空間容量
alter tablespace websms_data add datafile '/opt/oracle/oradata/websms/l2007test/raw15' size 500m reuse autoextend on next 512k maxsize unlimited, '/opt/oracle/oradata/websms/l2007test/raw16' size 500m reuse autoextend on next 512k maxsize unlimited, '/opt/oracle/oradata/websms/l2007test/raw17' size 500m reuse autoextend on next 512k maxsize unlimited, '/opt/oracle/oradata/websms/l2007test/raw18' size 500m reuse autoextend on next 512k maxsize unlimited
-- 禁用外來鍵
alter table corpmember disable constraint fk_corpmember_memberid
-- 啟用外來鍵
alter table corpmember enable constraint fk_corpmember_memberid
-- 檢視索引狀態
select index_name, index_type, tablespace_name, table_type, status
from user_indexes
where index_name = 'primary_messageinfo_bak';
-- 恢復索引
alter index primary_messageinfo_bak rebuild;
-- 看分割槽資訊
select u.table_name, u.partition_name
from user_tab_partitions u
where u.table_name = 'messagestatus_bak'
-- 刪除分割槽
alter table messagestatus_bak drop partition
messagestatus_bak20100730
-- 增加分割槽
alter table messageinfo_bak add partition
messageinfo_bak201007311232 values less
than(to_date('201007311232', 'yyyymmddhh24mi')) tablespace
d671_message_bak
-- 檢視鎖定的物件
select a.sid,
a.serial#,
a.username,
a.program,
c.owner,
c.object_name
from v$session a, v$locked_object b, all_objects c
where a.sid = b.session_id
and c.object_id = b.object_id;
-- 殺鎖定的物件
alter system kill session 'sid,#serial';
Oracle 常用命令
1 檢視當前所有物件 sql select from tab 2 建乙個和a表結構一樣的空表 sql create table b as select from a where 1 2 sql create table b b1,b2,b3 as select a1,a2,a3 from a whe...
oracle常用命令
create insert delete select 建立使用者必須在sys超級管理員下 連線到超級管理員 conn sys as sysdba sys zhuangyan system zhuangyan scott tiger 查出所有 clerk 辦事員 的姓名及其部門名稱,部門的人數.找出...
oracle 常用命令
建立臨時表空間 02createtemporarytablespace os temp 03tempfile c oracle product 10.2.0 oradata os temp.dbf 04size100m 05autoextendon 06next100m maxsize 1024m ...