September 2010
M T W T F S S
« Feb    
 12345
6789101112
13141516171819
20212223242526
27282930  

ORACLE IS_NUMBER FUNCTION

CREATE OR REPLACE FUNCTION is_number(char_in VARCHAR2) RETURN NUMBER IS
BEGIN
FOR x IN 1 .. LENGTH(char_in) LOOP
— remove , & .
IF SUBSTR(char_in,x,1) in (’,’ , ‘.’ , ‘ ‘) THEN
RETURN 0;
END IF;
END LOOP;

IF [...]

Export mysql to file

select * into outfile ‘/tmp/outfile.txt’ fields terminated by ‘,’ from my_table_name;

Rebuild all indexes once

declare
index_name VARCHAR2(100);
CURSOR i_c is select index_name from user_indexes;
begin
open i_c;
loop
fetch i_c into index_name;
EXIT WHEN i_c%NOTFOUND;
EXECUTE IMMEDIATE (’alter index ‘ || index_name || ‘ rebuild’);
end loop;
end;

Analysis query

explain plan for
SELECT * FROM (SELECT ROWNUM as nrow, USERNAME,NAME,to_char(STARTDATE,’YYYY-MM-DD’) as STARTDATE,to_char(EXPIRYDATE,’YYYY-MM-DD’) as EXPIRYDATE FROM USERS u) where nrow >= 100 and nrow

Fast Mysql Command from BASH

The powerful of shell is using quick command without run the program
mysql -u{user} {schema} -s -Be “SELECT NOW()”

BASH How to delete lines from a file by sed

1- Delete by Specific text
sed -i ‘/YOUR TEXT/ d’ file.log

2- Delete by line numbers
sed -i 10,+5d file.log

3- Delete Empty lines
sed -i ‘/^$/d’