(1)-- 创建一个新的小空间的undo tablespace
create undo tablespace undotBS4 datafile 'C:\oracle\oradata\dzq\eoffice\UNDOTBS4.DBF' size 500m;
(2)-- 设置新的表空间为系统undo_tablespace
alter system set undo_tablespace=undotBS4;
(3)-- Drop 旧的表空间
drop tablespace undotbs3 including contents;
==================================================================
select begin_time,end_time, undoblks from v$undosta
1)Only appropriate privileged user can do delete operation on SYS.AUD$ table. The user must have either of the following privileges.
-SYS user.
-DELETE ANY TABLE system privilege. (If O7_DICTIONARY_ACCESSIBILITY=TRUE)
-A user to whom SYS has granted the object privilege DELETE on SYS.AUD$ table.
2)Before deleting any rows you may want to archive the table. You can achive this by creating a table from SYS.AUD$ and export that. Don't export SYS.AUD$ directly.
SQL>CREATE TABLE AUDIT_RECORD TABLESPACE users as select * from SYS.AUD$;
Now export the table as,
SQL> host exp tables=AUDIT_RECORD file=audit_record.dmp
3)To delete all records from audit trail table SYS.AUD$ issue,
SQL>DELETE FROM SYS.AUD$;
To delete all records of particular audited table from the audit trail issue,
SQL>DELETE FROM sys.aud$ WHERE obj$name='&table_nmae';
But deleting in this way will not reduce size on the system tablespace or aud$ table. In order to reduce size follow section 4.
4)Truncate audit table to reduce size.
SQL>CONN / as sysdba
SQL>TRUNCATE TABLE SYS.AUD$
系统表空间异常扩展的情况遇到过很多:
有的和用户表空间或对象分配不当有关
有的和高级复制的空间使用有关....
经过如下代码查询,可以找出系统表空间中占用空间最多的Top9对象:
col segment_name for a25 col owner for a10 SELECT * FROM (SELECT BYTES, segment_name, segment_type, owner FROM dba_segments WHERE tablespace_name = 'SYSTEM' ORDER BY BYTES DESC) WHERE ROWNUM < 10 /
这个朋友的Top9对象为:
1 3082174464 IDL_UB1$ TABLE SYS 2 63979520 SOURCE$ TABLE SYS 3 12075008 IDL_UB2$ TABLE SYS 4 7749632 DEPENDENCY$ TABLE SYS 5 7356416 I_DEPENDENCY2 INDEX SYS 6 6438912 I_DEPENDENCY1 INDEX SYS 7 5521408 I_IDL_UB11 INDEX SYS 8 4341760 IDL_SB4$ TABLE SYS 9 3555328 I_ACCESS1 INDEX SYS
我们注意到占用空间最大的对象是IDL_UB1$系统表,空间占用近3G,那么这个表是做什么用的呢?
从sql.bsq中我们可以找到这个表的创建语句:
create table idl_ub1$ /* idl table for ub1 pieces */ ( obj# number not null, /* object number */ part number not null, /* part: 0 = diana, 1 = portable pcode, 2 = machine-dependent pcode */ version number, /* version number */ piece# number not null, /* piece number */ length number not null, /* piece length */ piece long raw not null) /* ub1 piece */ storage (initial 10k next 100k maxextents unlimited pctincrease 0) /
idl_ub1$表是用来存储PL/SQL的代码单元的,包括DIANA等,IDL在这里代表Interface Definition Language.
这个对象的含义可以从Ixora找到一点提示:
It is an intermediate language in which the structure of database tables and the logic of PL/SQL program units can be consistently represented as attributed trees. Oracle uses the DIANA IDL, which comes from compilers for the Ada programming language. DIANA stands for Descriptive Intermediate Attributed Notation for Ada. Anyway, this is one of four tables in the data dictionary used to store the DIANA for PL/SQL program units, and the database objects that they reference.
在高级复制中会用到这个表,所以可能导致这个表快速增长,在Oracle10g之前,高级复制需要考虑的事情的确很多。
ado执行存储过程,如果存储过程中包含结果集返回和输出参数,会导致获取输出参数为VT_EMPTY。目前没有找到对应的原因,网上有提相关问题但是也没人解决。有哪位大侠知道原因的请留个言,也为其他开发人员提供一个解决思路。
我目前的解决方法只能针对我遇到的情况。因为我使用的存储过程的返回结果集是中间结果集,不需要使用到,因此只要把返回结果集给去掉就行。不返回结果集的方法是在存储过程中加入SET NOCOUNT ON。
SET NOCOUNT
使返回的结果中不包含有关受 Transact-SQL 语句影响的行数的信息。
语法
SET NOCOUNT { ON | OFF }
注释
当 SET NOCOUNT 为 ON 时,不返回计数(表示受 Transact-SQL 语句影响的行数)。当 SET NOCOUNT 为 OFF 时,返回计数。
即使当 SET NOCOUNT 为 ON 时,也更新 @@ROWCOUNT 函数。
当 SET NOCOUNT 为 ON 时,将不给客户端发送存储过程中的每个语句的 DONE_IN_PROC 信息。当使用 Microsoft® SQL Server™ 提供的实用工具执行查询时,在 Transact-SQL 语句(如 SELECT、INSERT、UPDATE 和 DELETE)结束时将不会在查询结果中显示"nn rows affected"。
如果存储过程中包含的一些语句并不返回许多实际的数据,则该设置由于大量减少了网络流量,因此可显著提高性能。
maxS in number)
return varchar2 is
Result varchar2(5000);
minNum number;
maxNum number;
begin
select trunc(minS / 300001, 0) + 1 into minNum from dual;
select trunc(maxS / 300001, 0) + 1 into maxNum from dual;
while minNum <= maxNum loop
Result := Result || 'PART_' || minNum || '/';
minNum := minNum + 1;
end loop;
return(Result);
end transformPartition;