Monday, October 10, 2011

Search a value within all tables

DECLARE
match_count INTEGER;
BEGIN
FOR t IN (SELECT table_name, column_name FROM user_tab_cols) LOOP

EXECUTE IMMEDIATE
'SELECT COUNT(*) FROM '||t.table_name||' WHERE instr('||t.column_name||' , :1)>0'
INTO match_count
USING '01919323232';

IF match_count > 0 THEN
dbms_output.put_line( t.table_name ||' '||t.column_name||' '||match_count );
END IF;

END LOOP;

END;

Oracle sysdate fixed and back to Os date

ALTER SYSTEM SET fixed_date = '2011-01-01-10:00:00';

ALTER SYSTEM RESET fixed_date SCOPE=SPFILE SID='*';