Skip to content

Instantly share code, notes, and snippets.

View sytkov's full-sized avatar

Dmitry Sytkov sytkov

View GitHub Profile
@sytkov
sytkov / run_sql.sql
Last active December 24, 2015 13:59
dbms_xplan.display_cursor call example
select *
from table(
dbms_xplan.display_cursor(
( SELECT max(sql_id) keep (dense_rank first order by last_active_time desc)
FROM V$SQL
WHERE lower(sql_text) LIKE 'select /*+ gather_plan_statistics %'),
'',
'ALLSTATS ADVANCED LAST +PEEKED_BINDS'
)
);
@sytkov
sytkov / oracle.sql
Last active December 28, 2015 07:09
Gather table stats
declare
v_owner varchar2(4000) := '?';
type t_varchar2_tab is table of varchar2(4000);
v_tables t_varchar2_tab := t_varchar2_tab(
'?',
'?'
);
begin
for i in 1..v_tables.count loop
dbms_stats.gather_table_stats(
@sytkov
sytkov / oracle.sql
Last active August 29, 2015 13:56
Oracle. Comparing string with NULL
declare
v_string varchar2(4000) := '';
begin
if v_string = '' then
raise_application_error(-20000, 'It''s not working!');
else
raise_application_error(-20000, 'Hey, this is empty string!');
end if;
end;
/