檢視表空間日期處理

2021-09-01 03:11:59 字數 1892 閱讀 8662

--檢視表空間使用

select a.tablespace_name,a.bytes/1024/1024 "sum mb",(a.bytes-b.bytes)/1024/1024 "used mb",b.bytes/1024/1024 "free mb",round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"

from

(select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,

(select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b

where a.tablespace_name=b.tablespace_name

order by ((a.bytes-b.bytes)/a.bytes) desc

--增加表空間 資料檔案

alter tablespace bqdx add datafile 'f:\oracle\product\10.2.0\oradata\emp\bqdx03.dbf' size 20g;

--修改

alter database datafile 'g:\tablespace\pegnius01.dbf' resize 1500m;

--日期處理

select 'partition part_'||to_char(monthday-1, 'yyyymmdd') ||' less than ('||to_char(monthday, 'yyyy-mm-dd') ||'),'

from (select trunc(sysdate - 130, 'month') + rownum - 1 monthday

from all_objects

where rownum <= (select to_char(last_day(sysdate), 'dd') from dual))

--建立索引

create index sms_search_index1 on sms_search(c_send_num,d_send desc) local nologging parallel 8

---建立表空間

/*分為四步 */

/*第1步:建立臨時表空間 */

create temporary tablespace user_temp

tempfile 'd:\oracle\oradata\oracle9i\user_temp.dbf'

size 50m

autoextend on

next 50m maxsize 20480m

extent management local;

/*第2步:建立資料表空間 */

create tablespace test_data

logging

datafile 'd:\oracle\oradata\oracle9i\user_data.dbf'

size 50m

autoextend on

next 50m maxsize 20480m

extent management local;

/*第3步:建立使用者並指定表空間 */

create user username identified by password

default tablespace user_data

temporary tablespace user_temp;

/*第4步:給使用者授予許可權 */

grant connect,resource,dba to username;

檢視表空間

檢視某錶的大小 select sum bytes 1024 1024 as size m from user segments where segment name upper tbl mo part 00 檢視索引個數和類別 select index name,index type,table n...

sqlserver檢視表空間

sqlserver 用於檢視當前資料庫所有表占用空間大小的儲存過程 create procedure dbo.proc getsize asbegin create table temp t id intprimary keyidentity 1,1 t name sysname,表名 t rows...

檢視表占用空間資訊

if not exists select from dbo.sysobjects where id object id n dbo tablespaceinfo and objectproperty id,n isusertable 1 create table tablespaceinfo 建立臨...