This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with v(a) as (select to_char(n,'fm0000') from xmltable('9741,2415,9100,5532' columns n int path'.')) | |
select | |
a | |
,translate( | |
regexp_replace( | |
'0a0b0c0d1a1b1c1d2a2b2c2d3a3b3c3d4a4b4c4d5a5b5c5d6a6b6c6d7a7b7c7d8a8b8c8d9a9b9c9d' | |
,'(' | |
||substr(a,1,1)||'a|' | |
||substr(a,2,1)||'b|' | |
||substr(a,3,1)||'c|' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set echo on feed on serverout off; | |
create table tpart (pkey int, notkey int,padding varchar2(4000)) | |
partition by range(pkey) | |
( | |
partition p1 values less than (2) | |
,partition p2 values less than (3) | |
,partition p3 values less than (4) | |
); | |
insert into tpart(pkey,notkey,padding) | |
select ceil(n/1000) pkey, n, rpad('x',4000,'x') from xmltable('1 to 3000' columns n int path '.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table t (a int,b int, c int, d int); | |
insert into t select 1, 1, level,level from dual connect by level<=100; | |
insert into t select 1, 5, level,level from dual connect by level<=100000; | |
insert into t select 1, 6, level,level from dual connect by level<=100000; | |
insert into t select 1, 7, level,level from dual connect by level<=100000; | |
insert into t select 10, 10, level,level from dual connect by level<=1; | |
insert into t select 11, 11, level,level from dual connect by level<=1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
procedure test_hint(p_hint varchar2) is | |
cmd varchar2(200); | |
begin | |
cmd:=replace(q'[explain plan set statement_id='{hint}' for select /*+ {hint} */ 1 from dual]','{hint}',p_hint); | |
execute immediate cmd; | |
exception when others then | |
dbms_output.put_line(cmd); | |
dbms_output.put_line(sqlerrm); | |
end; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQL> create table dates(date_col, padding) as select date'2020-01-01' + level*5/24/60, level from dual connect by level<=10000; | |
SQL> create index ix_dates_trunc on dates(trunc(date_col)); | |
SQL> exec dbms_stats.gather_table_stats('','DATES'); | |
SQL> select min(date_col),max(date_col),count(*) from dates where date_col=to_date('2020-01-15 01:15','yyyy-mm-dd hh24:mi'); | |
MIN(DATE_COL) MAX(DATE_COL) COUNT(*) | |
------------------- ------------------- ---------- | |
2020-01-15 01:15:00 2020-01-15 01:15:00 1 | |
SQL> select * from dbms_xplan.display_cursor('','','allstats last -projection -alias'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQL> set feed on sql_id | |
SQL> select/*+ no_merge 123 */ * from dual; | |
D | |
- | |
X | |
1 row selected. | |
SQL_ID: 6zsqx79h3usgq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with | |
function raw_to_date(i_raw raw) | |
return date | |
as | |
m_n date; | |
begin | |
dbms_stats.convert_raw_value(i_raw,m_n); | |
return m_n; | |
end; | |
function val(p_datatype varchar2,p_value varchar2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table ttt (aaa varchar2(10),bbb varchar2(10)); | |
declare | |
cur integer; | |
str varchar2(100):='insert into ttt ("no","cols") values ("no such","column here")'; | |
err_position int; | |
begin | |
cur := dbms_sql.open_cursor; | |
dbms_sql.parse(cur, str, | |
dbms_sql.native); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with t as (select 'aaa,asdf,2,3,3,4,5,,123,,,zz' s from dual) | |
select * | |
from t outer apply str_split(t.s, ',') | |
/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with | |
t(name,id1,id2) as ( | |
select 'A', to_date('01.01.2020','dd.mm.yyyy'),to_date('01.02.2023','dd.mm.yyyy') from dual union all | |
select 'A', to_date('12.12.2021','dd.mm.yyyy'),to_date('20.05.2022','dd.mm.yyyy') from dual union all | |
select 'A', to_date('12.12.2022','dd.mm.yyyy'),to_date('30.01.2023','dd.mm.yyyy') from dual union all | |
select 'A', to_date('01.03.2023','dd.mm.yyyy'),to_date('01.04.2023','dd.mm.yyyy') from dual union all | |
select 'A', to_date('01.01.2020','dd.mm.yyyy'),to_date('01.01.2024','dd.mm.yyyy') from dual union all | |
select 'В', to_date('01.02.2020','dd.mm.yyyy'),to_date('01.04.2023','dd.mm.yyyy') from dual union all | |
select 'В', to_date('01.05.2023','dd.mm.yyyy'),to_date('01.01.2024','dd.mm.yyyy') from dual union all | |
select 'А', to_date('01.02.2024','dd.mm.yyyy'),to_date('01.03.2024','dd.mm.yyyy') from dual union all |
NewerOlder