服务器 频道

Oracle 基本知识及问题解决

5、创建表

create table test_name1

(

a NUMBER(10) not null,

b NUMBER(10) null ,

c NUMBER(3) defalut 0,

d number(3) not null ,

constraint PK_ test_user primary key (a)

using index

tablespace test_name1

storage

(

initial 1m

next 1m

pctincrease 0

)

)

pctfree 10

tablespace test_name1

storage

(

initial 1m

next 1m

pctincrease 0

)

partition by range(d)

(partition part000 values less than (1) tablespace test_name1,

partition part001 values less than (2) tablespace test_name1,

)

/

6、创建索引

create index id_tablename1 on test_name1 (f2)

tablespace ts_name

storage

(

initial 500k

next 500k

pctincrease 0

)

/

三、查询表空间

select substr(a.TABLESPACE_NAME,1,10) TablespaceName,

sum(a.bytes/1024/1024) totle_size,

sum(nvl(b.free_space1/1024/1024,0)) free_space,

sum(a.bytes/1024/1024)-sum(nvl(b.free_space1/1024/1024,0)) used_space,

round((sum(a.bytes/1024/1024)-sum(nvl(b.free_space1/1024/1024,0)))*100/sum(a.bytes/1024/1024),2) used_percent

from dba_data_files a,

(select sum(nvl(bytes,0)) free_space1,file_id

from dba_free_space

group by file_id) b

where a.file_id = b.file_id(+)

group by a.TABLESPACE_NAME

0
相关文章