Month: April 2010

Script to send email unix with sendmail

Plain text email: cat << EOF | /usr/sbin/sendmail -t to: from: “no reply” (Automated Processor) subject: My subject My email body. EOF Or HTML formatted email: cat

Posted in Email

du -sk to identify space usage unix

Find 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 * |

Posted in Linux, Space

Materialized Views with dbms_metadata.get_ddl

See 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

Posted in Materialized views

dbms_stats export import optimizer statistics

Examples 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

Posted in Stats

Keep log files by copying into new directory unix

cp -pR logs logs`date +$d%m%y%T` Creates a timestamped copy directory named like “logs041015:44:42”.

Posted in Linux