Search This Blog

Total Pageviews

Thursday, 24 November 2011

nohup sql script

$ nohup sqlplus system/sys @hwm2.sql>hwm2.txt 2>&1 &


nohup sqlplus '/ as sysdba' @stats.sql &

cat stats.sql

spool stats.spool
set time on timing on
alter session set nls_date_format='dd-mm-yyyy hh24:mi';
prompt dbms_stats.gather_dictionary_stats
EXECUTE dbms_stats.gather_dictionary_stats;

prompt DBMS_STATS.GATHER_FIXED_OBJECTS_STATS
EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;
spool off
exit

============

--  stats1.sql
spool stats1.spool
alter session set nls_date_format='dd-MON-YYYY hh24:mi'; 


set time on timing on feedback on 
select sysdate from dual;
set echo on feedback on time on timing on verify on

-- show con_name;
set pages 300 lines 350
col open_mode for a10
col host_name for a10
col database_role for a15
col db_unique_name for a10
col controlfile_type for a10
col database_role for a17
col host_name for a35
col open_mode for a20
select name,db_unique_name,instance_name,host_name,open_mode,log_mode,database_status,database_role,switchover_status,protection_mode,protection_level,controlfile_type,status,logins,force_logging,to_char(startup_time,'dd-mon-yyyy hh24:mi:ss') "db up time" from v$database,gv$instance;


SET VERIFY OFF

select sysdate from dual;


prompt ========================================
prompt DBMS_STATS.GATHER_FIXED_OBJECTS_STATS ()
prompt ========================================

EXEC DBMS_STATS.GATHER_FIXED_OBJECTS_STATS ();


prompt ========================================
prompt DBMS_STATS.GATHER_SCHEMA_STATS('SYSTEM')
prompt ========================================

EXEC DBMS_STATS.GATHER_SCHEMA_STATS('SYSTEM');


prompt ========================================
prompt DBMS_STATS.GATHER_SCHEMA_STATS('SYS')
prompt ========================================

EXEC DBMS_STATS.GATHER_SCHEMA_STATS('SYS');

prompt ========================================
prompt DBMS_STATS.GATHER_DICTIONARY_STATS
prompt ========================================

EXEC DBMS_STATS.GATHER_DICTIONARY_STATS ();

select sysdate from dual;

spool off


5 comments:

Anuj Singh said...

nohup /export/home/oracle/restore.sh > /export/home/oracle/restore_`date '+%Y%m%d_%H%M%S'`.log 2>&1 &

Anuj Singh said...

nohup /export/home/oracle/restore.sh > /export/home/oracle/restore_`date '+%Y%m%d_%H%M%S'`.log 2>&1 &

Anuj Singh said...

nohup sqlplus "/ as sysdba" @.sql &

Anuj Singh said...

http://anuj-singh.blogspot.co.uk/2011/02/oracle-sqlplus-unix-nohup.html

Anuj Singh said...


cat /home/oracle/dual.sh
#!/bin/bash
export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1
export ORACLE_SID=vih8
export PATH=$ORACLE_HOME/bin:$PATH
$ORACLE_HOME/bin/sqlplus -s / as sysdba << EOF
spool /var/log/oracle/dual.txt
@/home/oracle/dual.sql
spool off
exit
EOF



nohup /home/oracle/dual.sh > /home/oracle/dualf.txt 2>/dev/null &


cat dualf.txt

D
-
X

Elapsed: 00:00:00.00

Oracle DBA

anuj blog Archive