EAS清除临时表步骤
金蝶云社区-王秀珩
王秀珩
19人赞赏了该文章 8,529次浏览 未经作者许可,禁止转载编辑于2017年02月14日 15:22:19

Oracle数据库:
1. 停止所有实例管理控制台——群集控制器 界面,可以停止所有实例,或者在管理控制台——应用服务器 界面一个一个停止实例,直到所有实例停止。2. 连接EAS数据库实例例如,通过命令行sqlplus连接数据库:打开cmd命令窗口,输入sqlplus 用户名/密码@数据库实例名或是通过PL/SQL developer软件连上Oracle数据库

3. 执行下面查询语句,先查出哪些表,看看这些表能不能删,如果查询出来的都是临时表,再执行上面的删除语句(所谓的临时表,就是表名以VT开头,表名包含一大串数字和字母,类似这种表名VTOS8TE3N61US0XKTFY68GNT2)
select * from user_tables wheretablespace_name='原EAS数据表空间名(存有VT开头的临时表)' AND table_name LIKE 'VT%';
4.如果确认查询出的表都是临时表,则执行下面语句(表空间名换成现场的表空间)spool d:\dop_temp_table.sqlselect 'drop table eas用户名.'||table_name||' purge;' as"--drop temptable" from user_tables where tablespace_name='原EAS数据表空间名(存有VT开头的临时表)' and table_name like 'VT%';spool off
5.对在D盘生成的dop_table.sql文件进行编辑,去掉不必要的部分(原则上都要),只留下drop table … purge; 语句
6. 编辑完dop_table.sql后,执行该sql文件@d:\dop_temp_table.sql
[hr]
方法二:
Oracle环境可以使用下面的脚本直接操作:
declare
cursor c_droptemptable
is select table_name
from user_tables
WHERE table_name like 'VT%'
and user_tables.TABLESPACE_NAME='EAS_D_EAS75_STANDARD'
--EAS_D_EAS75_STANDARD为存放VT临时表的表空间名称,现场需要修改

--默认一次删除1W个,如果超过此数量,可重复执行直到全部删除VT表为止

and rownum<=10000;
c_row c_droptemptable%rowtype;
begin
for c_row in c_droptemptable loop
dbms_output.put_line('drop table '||c_row.table_name||' purge;');
execute immediate 'drop table '||c_row.table_name||' purge' ;
end loop;
end;

[hr]sqlserver数据库:[hr]
--定义游标删除VT表declare c1 cursor for select name from sysobjects where name like 'VT%';open c1;declare @table_name varchar(100);DECLARE @SQLString NVARCHAR(500)fetch c1 into @table_name while(@@fetch_status=0)beginSET @SQLString = N'drop table ' + @table_nameEXEC(@SQLString)fetch next from c1 into @table_name; end close c1;deallocate c1;