我要运行的文件如下:
inserts.sql
set verify off
@ins_all LINK_CAM.SVCC
@ins_all CC1
analyze table files compute statistics;
analyze table spaces compute statistics;
analyze table extents compute statistics;
@space_watcher
@extent_watcher
另一个文件:
ins_all.sql
insert into files
(db_nm,ts,check_date,file_nm,blocks)
select upper('&1'),tablespace_name,trunc(sysdate),file_name,blocks
from sys.dba_data_files@&1
/
commit;
rem
insert into spaces
(db_nm,check_date,ts,count_free_blocks,sum_free_blocks,max_free_blocks)
select upper('&1'),
trunc(sysdate),tablespace_name,count(blocks),sum(blocks),max(blocks)
from sys.dba_free_space@&1
group by tablespace_name
/
commit;
rem
insert into extents
(db_nm,ts,seg_owner,seg_name,seg_type,extents,blocks,check_date)
select upper('&1'),tablespace_name,owner,segment_name,segment_type,extents,blocks,trunc(sysdate) from sys.dba_segments@&1
where extents>9 or segment_type = 'ROLLBACK'
/
commit;
rem
undefine 1
其中:LINK_CAM.SVCC为DATABASE LINK,我在Sqlplus下已经试验成功了:
select * from dba_data_files@LINK_CAM.SVCC;
得到正确结果,我在操作系统下调用的错误信息如下:
[oracle@localhost create_script]$ sh ins_cc1
ORACLE_SID = [CC1] ?
Oracle Server Manager Release 3.1.7.0.0 - Production
Copyright (c) 1997, 1999, Oracle Corporation. All Rights Reserved.
Oracle8i Enterprise Edition Release 8.1.7.0.1 - Production
With the Partitioning option
JServer Release 8.1.7.0.1 - Production
SVRMGR> Connected.
SVRMGR> MGR-00110: illegal SET option
from sys.dba_data_files@&1
*
ORA-01729: database link name expected
Statement processed.
from sys.dba_free_space@&1
*
ORA-01729: database link name expected
Statement processed.
select upper('&1'),tablespace_name,owner,segment_name,segment_type,extents,blocks,trunc(sysdate) from sys.dba_segments@&1
*
ORA-01729: database link name expected
Statement processed.
undefine 1
*
ORA-00900: invalid SQL statement
from sys.dba_data_files@&1
*
ORA-01729: database link name expected
Statement processed.
from sys.dba_free_space@&1
*
ORA-01729: database link name expected
Statement processed.
select upper('&1'),tablespace_name,owner,segment_name,segment_type,extents,blocks,trunc(sysdate) from sys.dba_segments@&1
*
ORA-01729: database link name expected
Statement processed.
undefine 1
*
ORA-00900: invalid SQL statement
analyze table files compute statistics
*
ORA-00942: table or view does not exist
analyze table spaces compute statistics
*
ORA-00942: table or view does not exist
analyze table extents compute statistics
*
ORA-00942: table or view does not exist
column db_nm foramt A8
*
ORA-00900: invalid SQL statement
MGR-00308: no spool file opened
MGR-01507: unable to open file "extent_watcher.sql"
SVRMGR>
Server Manager complete.
是什么原因呢????