shell和sqlplus互動
阿新 • • 發佈:2018-11-22
[[email protected] ~]$ more oracle_connect.sh #!/bin/bash #表空間使用狀態 sqlplus -S / as sysdba >connect_oracle.txt <<EOF select 'information_database' from dual; select * from v\$version; archive log list; select 'undo_tablespace_information' from dual; show parameter undo; select 'datafile_information' from dual; set linesize 200; col name for a50; select file#,status,CHECKPOINT_CHANGE#,last_change#,bytes/1024/1024 M,name from v\$datafile; select 'index_and_constraints_information_about_user_scott' from dual; set linesize 300; select u.index_name,u.index_type,u.table_name,u.table_type,u.status, c.constraint_name,c.constraint_type,c.status from dba_indexes u left join dba_constraints c on u.table_owner=c.owner where u.table_owner='SCOTT'; select 'dump_file_path' from dual; set linesize 100; SELECT pa.value || '/' || i.instance_name || '_ora_' || pr.spid || '.trc' AS trace_file FROM v\$session s, v\$process pr, v\$parameter pa, v\$instance i WHERE s.username = USER AND s.paddr = pr.addr AND pa.name = 'user_dump_dest'; EOF
[[email protected] ~]$ more connect_oracle.txt 'INFORMATION_DATABAS -------------------- information_database BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for Linux: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 17 Next log sequence to archive 19 Current log sequence 19 'UNDO_TABLESPACE_INFORMATIO --------------------------- undo_tablespace_information NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ undo_management string AUTO undo_retention integer 900 undo_tablespace string UNDOTBS1 'DATAFILE_INFORMATIO -------------------- datafile_information FILE# STATUS CHECKPOINT_CHANGE# LAST_CHANGE# M NAME ---------- ------- ------------------ ------------ ---------- -------------------------------------------------- 1 SYSTEM 1158884 770 /u01/app/oracle/oradata/PROD/system01.dbf 2 ONLINE 1158884 610 /u01/app/oracle/oradata/PROD/sysaux01.dbf 3 ONLINE 1158884 105 /u01/app/oracle/oradata/PROD/undotbs01.dbf 4 ONLINE 1158884 6.25 /u01/app/oracle/oradata/PROD/users01.dbf 5 ONLINE 1158884 345.625 /u01/app/oracle/oradata/PROD/example01.dbf 6 ONLINE 979501 979501 10 /u01/app/oranfs/lfn_nfs.dbf 6 rows selected. 'INDEX_AND_CONSTRAINTS_INFORMATION_ABOUT_USER_SCOT -------------------------------------------------- index_and_constraints_information_about_user_scott INDEX_NAME INDEX_TYPE TABLE_NAME TABLE_TYPE STATUS CONSTRAINT_NAME C STATUS ------------------------------ --------------------------- ------------------------------ ----------- -------- ------------------------------ - -------- PK_EMP NORMAL EMP TABLE VALID FK_DEPTNO R ENABLED PK_DEPT NORMAL DEPT TABLE VALID FK_DEPTNO R ENABLED PK_EMP NORMAL EMP TABLE VALID SYS_C0011481 C ENABLED PK_DEPT NORMAL DEPT TABLE VALID SYS_C0011481 C ENABLED PK_EMP NORMAL EMP TABLE VALID PK_DEPT P ENABLED PK_DEPT NORMAL DEPT TABLE VALID PK_DEPT P ENABLED PK_EMP NORMAL EMP TABLE VALID PK_EMP P ENABLED PK_DEPT NORMAL DEPT TABLE VALID PK_EMP P ENABLED 8 rows selected. 'DUMP_FILE_PAT -------------- dump_file_path TRACE_FILE ---------------------------------------------------------------------------------------------------- /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_ora_6930.trc /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_ora_6715.trc