This file contains 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 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 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 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 |
This file contains 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 t as (select/*+ materialize */ decode(owner,'SYS','SYS','SYSTEM','SYSTEM','OTHERS') owner, object_type from dba_objects); | |
Table created. | |
SQL> explain plan for | |
2 select * | |
3 from t | |
4 pivot ( | |
5 count(*) for owner in ('SYS','SYSTEM','OTHERS') | |
6 ); |
This file contains 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> select to_char(systimestamp,'dd.mm.yyyy hh24:mi:ss.ff6') from dual | |
2 union all | |
3 select to_char(count(*)) from dba_objects,dba_tables | |
4 union all | |
5 select to_char(localtimestamp,'dd.mm.yyyy hh24:mi:ss.ff6') from dual | |
6 / | |
TO_CHAR(SYSTIMESTAMP,'DD.MM.YYYYHH24:MI: | |
---------------------------------------- | |
04.05.2023 11:13:14.432061 |
This file contains 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
select | |
o.obj# , o.owner# , o.name , o.namespace, | |
o.type# , o.ctime , o.stime, o.status, | |
o.flags , o.oid$ , o.signature, | |
--o.dflcollid, | |
'type' d, | |
t.typecode,t.hashcode, | |
'coll', | |
c.* | |
,s.* |
This file contains 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> @tests/patch_fm.sql | |
SQL> create table test(n,x, constraint test_pk primary key(n)) | |
2 as select level n, level x from dual connect by level<=100; | |
Table created. | |
SQL> set serverout on; | |
SQL> declare | |
2 res varchar2(4000); | |
3 begin |
This file contains 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_BOP_DSCR_STD_dbg as | |
select | |
systimestamp tmp | |
,cast(null as varchar2(100)) bind_code | |
,s.sid, s.serial# | |
,t.* | |
from T_BOP_DSCR_STD t, v$session s | |
where 1=0; | |
create table T_BOP_DSCR_STD_dbg_trans | |
as select |
This file contains 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
-- more extended version is here: https://github.com/xtender/xt_scripts/blob/master/tops/top_by_sesstat.sql | |
var c refcursor; | |
col username for a30; | |
col program for a20 trunc; | |
col osuser for a20 trunc; | |
declare | |
v_stat1 sys.ku$_objnumpairlist; | |
v_stat2 sys.ku$_objnumpairlist; |
NewerOlder