cat << EOF | /usr/sbin/sendmail -t to:myemail@mysite.com from:"no reply" (Automated Processor) subject:My subject My email body. EOF
Archive for April, 2010
Script to send email unix with sendmail
Friday, April 9th, 2010du -sk to identify space usage unix
Thursday, April 8th, 2010Find out what directories are using up disk space in unix with this command:
du -sk * | sort -n
I often put it into a function so I can call it quickly:
g () {
du -sk * | sort -n
}
df -h (df -k on old machines) shows the filesystem disk utilisation.
Materialized Views with dbms_metadata.get_ddl
Wednesday, April 7th, 2010See the SQL create definition of a materialized view by running this SQL:
set long 200000 pages 0 lines 131 doc off
column txt format a121 word_wrapped
spool recreate_sql
select dbms_metadata.get_ddl('MATERIALIZED_VIEW','my_mv_name','my_owner') txt from dual;
spool off
set pages 9999
Look especially for the refresh option, e.g.:
REFRESH FORCE ON DEMAND NEXT null
There are three normally used refresh options:
- Fast = use materialized view logs on source
- Complete = ignore materialized view logs, instead truncate the materialized view and repopulate it from the base tables of source.
- Force = exactly the same as Fast – except when there are no materialized view logs on source, in which case it does a complete refresh.
dbms_stats export import optimizer statistics
Wednesday, April 7th, 2010Examples of syntax to export/import dbms_stats:
exec dbms_stats.create_stat_table ( ownname => user , stattab => 'temp_stats' ) ; exec dbms_stats.export_table_stats ( ownname => user , stattab => 'temp_stats', tabname => 'mytable', statid => 'Taken_7Apr2010') ; exec dbms_stats.import_table_stats ( ownname => user , stattab => 'temp_stats', tabname => 'adm_fact' )
Similarly for schema:
exec DBMS_STATS.EXPORT_SCHEMA_STATS ( ownname => 'myowner' , stattab => 'temp_stats', statown => user )
A bug in 10g prevents spaces being passed into the “statid” variable, hence the underscores in the above example.
Keep log files by copying into new directory unix
Wednesday, April 7th, 2010cp -pR logs logs`date +$d%m%y%T`
Creates a timestamped copy directory named like “logs041015:44:42″.