ORACLE应用经验(5)-表空间

发表于:2007-07-01来源:作者:点击数: 标签:
一、进入oracle下 # su - oracle as4101 lsnrctl start as4101 svrmgrl svrmgrl connect internal; svrmgrl shu td own immediate; svrmgrl startup 二、查看有哪些表空间 svrmgrl SELECT * FROM DBA_TABLESPACES; SYSTEM RBS TEMP TOOLS USERS 三、将USERS表
一、进入oracle下
# su - oracle
as4101> lsnrctl start
as4101> svrmgrl
svrmgrl> connect internal;
svrmgrl> shutdown immediate;
svrmgrl> startup
二、查看有哪些表空间
svrmgrl> SELECT * FROM DBA_TABLESPACES;
SYSTEM RBS TEMP TOOLS USERS
三、将USERS表空间DROP
svrmgrl> ALTER TABLESPACE USERS OFFLINE;
svrmgrl> DROP TABLESPACE USERS;
四、查看表空间的空余大小
svrmgrl> SELECT TABLESPACE_NAME,SUM(BYTES)/1024/1024 MB
FROM DBA_FREE_SPACE GROUP BY TABLESPACE_NAME;

TABLESPACE_NAME MB
------------------------------ ---------
DD_DATA 1136.3672
DD_IDX 787.18164
JX_DATA 827.94531
JX_IDX 503.16016
RBS 371.9668
SYSTEM 457.81445
TEMP 1499.9961
TOOLS 36.462891

五、查看数据文件放置的路径
svrmgrl> SELECT TABLESPACE_NAME,BYTES/1024/1024 MB,FILE_NAME
FROM DBA_DATA_FILES;
TABLESPACE_NAME MB FILE_NAME
------------------------------ --------- ---------------
SYSTEM 500 /dev/rdrd/drd4
RBS 500 /dev/rdrd/drd14
RBS 1000 /dev/rdrd/drd15
RBS 500 /dev/rdrd/drd32
TOOLS 50 /dev/rdrd/drd5
TEMP 1000 /dev/rdrd/drd22
TEMP 500 /dev/rdrd/drd23
JX_DATA 500 /dev/rdrd/drd33

六、对应SYSTEM表空间有一个回退段,为SYSTEM,另有一些回退段是属于RBS的,
先将RBS下的回退段都OFFLINE,并DROP,然后将RBS表空间DROP并重新创建,
最后,创建回退段。回退段4个,每个大小为RBS/4,这个值可以当作OPTIMAL值,
即等于INITIAL+NEXT*MAXEXTENTS

svrmgrl> ALTER ROLLBACK SEGMENT R01 OFFLINE;
svrmgrl> DROP ROLLBACK SEGMENT R01;
svrmgrl> alter tablespace rbs offline;
svrmgrl> drop tablespace rbs;
svrmgrl> Create TABLESPACE "RBS" DATAFILE
@#/dev/rdrd/rbs01.ora@# SIZE 500M,
@#/dev/rdrd/rbs02.ora@# SIZE 500M;
svrmgrl> CREATE ROLLBACK SEGMENT "R01" TABLESPACE "RBS"
STORAGE ( INITIAL 200M NEXT 2M OPTIMAL 250M
MINEXTENTS 2 MAXEXTENTS 25);

七、查看回退段及表空间的状态,若为ONLINE,即结束,为OFFLINE,要ONLINE
svrmgrl> select SEGMENT_NAME,TABLESPACE_NAME,status from DBA_ROLLBACK_SEGS;
svrmgrl> ALTER ROLLBACK SEGMENT R01 ONLINE;

八、临时表空间TEMP,先DROP,再重建。
svrmgrl> alter tablespace temp offline;
svrmgrl> drop tablespace temp;
svrmgrl> CREATE TABLESPACE temp DATAFILE
@#/dev/rdrd/drd22@# SIZE 1000M storage (initial 300m next 20m
minextens 2 maxextents 35 pctincrease 0);

九、工具表空间TOOLS大小为50M足够用,系统表空间SYSTEM为100M足够用。

十、创建数据表空间:
DD_DATA、DD_IDX、JX_DATA、JX_IDX、SF_DATA、SF_IDX、JF_DATA、JF_IDX

svrmgrl> CREATE TABLESPACE dd_data DATAFILE
@#/dev/rdrd/drd9@# SIZE 1000M,
@#/dev/rdrd/drd10@# SIZE 1000M,
@#/dev/rdrd/drd26@# SIZE 1000M,
@#/dev/rdrd/drd35@# SIZE 1000M,
@#/dev/rdrd/drd42@# SIZE 500M;

十一、创建用户
svrmgrl> CREATE USER ddbh IDENTIFIED BY ddbh
DEFAULT TABLESPACE dd_data
TEMPORARY TABLESPACE temp
QUOTA UNLIMITED ON dd_data
QUOTA UNLIMITED ON dd_idx
QUOTA UNLIMITED ON rbs
QUOTA UNLIMITED ON temp;

十二、用户权限
svrmgrl> grant connect,resources,imp_full_database,exp_full_database,
create public synonym,drop public synonym to ddbh;

若要查看V$SESSION,KILL SESSION, DROP USER,CREATE USER等,则

svrmgrl> grant select on v_$session to public;
svrmgrl> grant alter system,drop user,create user to "*******";

原文转自:http://www.ltesting.net