Friday, 22 July 2005

How to create / read unix tar files

To create a unix tar file supply the path to the directory which you want to tar in the 'directoryname' below:

$ tar cvf filename.tar directoryname


To extract a tar file into a directory supply the path to the 'directoryname' as below.

$ tar xvf filename.tar directoryname

Thursday, 5 May 2005

Import time monitoring

Use this script to monitor how long the import into a table takes and how many rows have already been imported. Log in as sysdba to do that.

It shows how many rows are already imoprted dymamically. If you already know how many rows you have in the table it is very handy and you can see the progress of your import.

select substr(sql_text,instr(sql_text,'INTO "'),30)
table_name, rows_processed, round((sysdate- to_date(first_load_time,'yyyy-
mm-dd hh24:mi:ss'))*24*60,1) minutes,
trunc(rows_processed/ ((sysdate-to_date(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60)
) rows_per_minute from sys.v_$sqlarea where sql_text like 'INSERT %INTO "%'
and command_type = 2 and open_versions > 0
/

Tuesday, 12 April 2005

Delete files older than X certain days

To delete files older than certain days you use -mtime argument of the find command like this. The following example deletes files which start with the word 'control.' and older than 3 days. That is keeps only the files of the last 3 days and removes the rest.

$ find control.* -mtime +3 -print -exec rm -f {} \;

Friday, 25 February 2005

See what's in the DB_CACHE_BUFFER

See what's in you db_cache buffer at that time, log on as SYSDBA and run the following query.
You will see what occupies the db_cache buffer at that time.


OLUMN object_name FORMAT a40
COLUMN number_of_blocks FORMAT 999,999,999,999

SELECT o.object_name, COUNT(1) number_of_blocks
FROM DBA_OBJECTS o, V$BH bh
WHERE o.object_id = bh.objd
AND o.owner != 'SYS'
GROUP BY o.object_name
ORDER BY count(1);

Wednesday, 16 February 2005

Solaris ls command to list large files

Use this command on Solaris with bash, to get your files sorted from the smallest to the largest and quickly list large files.

$ ls -lhs | sort -nSk5

Note: k5 is the column number from left to right (in this example column 5). if your filesizes are displayed on the 3rd column you put ..k3. All depends on which column the command ls -l displays the filesizes.