Skip to content

Instantly share code, notes, and snippets.

View Tracnac's full-sized avatar

Tracnac

View GitHub Profile
@Tracnac
Tracnac / Escape wildcard characters.md
Created October 19, 2022 11:42
Escape wildcard characters #oracle #sql

Escape wildcard characters The LIKE keyword allows for string searches. The '_' wild card character is used to match exactly one character, while '%' is used to match zero or more occurrences of any characters. These characters can be escaped in SQL. Examples:

SELECT name FROM emp
WHERE id LIKE '%/_%' ESCAPE '/';


SELECT name FROM emp
WHERE id LIKE '%\%%' ESCAPE '\';
@Tracnac
Tracnac / Evolution d'une table oracle.md
Created October 19, 2022 11:41
Evolution d'une table oracle #oracle #sql
col c1 format a15 heading 'snapshot|date'
col c2 format a25 heading 'table|name'
col c3 format 999,999,999,999 heading 'space|used|total'
col c4 format 999,999,999,999 heading 'space|allocated|total'


select
to_char(begin_interval_time,'yy/mm/dd hh24:mm') c1,
object_name c2,
@Tracnac
Tracnac / Exec unix command from via external table.md
Created October 19, 2022 11:41
Exec unix command from via external table #oracle #sql

ops$tkyte%ORA11GR2> !cat /tmp/run_ls.sh #/bin/bash cd /tmp /bin/ls -l

ops$tkyte%ORA11GR2> CREATE or replace DIRECTORY exec_dir AS '/tmp' 2 /

@Tracnac
Tracnac / Frag d'une table blocs oracle.md
Last active October 19, 2022 11:40
Frag d'une table blocs oracle #oracle #sql
select current_block,next_block,max(level)
from (select block_id as current_block,block_id+BLOCKS as next_block from dba_extents where owner='<OWNER>' and SEGMENT_NAME='CONT' order by current_block) blocks
connect by prior next_block=current_block
group by current_block,next_block
order by current_block;
@Tracnac
Tracnac / Recover vs Applied.md
Last active October 19, 2022 11:39
Recover vs Applied #oracle #sql
sqlplus -s / as sysdba << EOF
ALTER SESSION SET NLS_DATE_FORMAT='DD-MON-RR HH24:MI:SS';
select '${i}' from dual;
select SEQUENCE#,first_time from v\$archived_log where sequence# = (select max(sequence#) from v\$archived_log) order by first_time;
select sequence#, first_time from v\$archived_log where (select resetlogs_change# from v\$database) between first_change# and next_change#;
quit
@Tracnac
Tracnac / Garmin etrex reset.md
Created October 19, 2022 11:38
Garmin etrex reset #gps
  • Power off device
  • Press and hold Menu and Enter (joystick pressed in)
  • Press and release Light while continuing to hold Menu and Enter
  • Select Yes once the Do you really want to erase all user data? message appears
  • Leave the device outside with a clear view of the sky for a minimum of 20 minutes to acquire satellite data.
@Tracnac
Tracnac / Get env from oracle.md
Last active October 19, 2022 11:38
Get env from oracle #oracle #sql
1 DECLARE
2 RetVal VARCHAR2(100);
3 BEGIN
4 dbms_system.get_env('ORACLE_HOME', RetVal);
5 dbms_output.put_line(RetVal);
6* END;
@Tracnac
Tracnac / Hidden value vparameter.md
Created October 19, 2022 11:36
Hidden value v$parameter #oracle #sql
col "Parameter" for a48
col "Session Value" for a32
col "Instance Value" for a32
select a.ksppinm "Parameter", b.ksppstvl "Session Value", c.ksppstvl "Instance Value"
from x$ksppi a, x$ksppcv b, x$ksppsv c
where a.indx = b.indx and a.indx = c.indx
and substr(ksppinm,1,1)='_'
and ksppinm like '%&1.%'
order by a.ksppinm;
@Tracnac
Tracnac / Identification des problèmes sur foreignkeys.md
Last active October 19, 2022 11:35
Identification des problèmes sur foreignkeys #oracle #sql
SELECT DECODE (b.table_name, NULL, 'dead', 'ok') status,
a.table_name,
a.columns fk_columns,
b.columns index_columns
FROM ( SELECT a.table_name,
a.constraint_name,
LISTAGG (a.column_name, ',')
WITHIN GROUP (ORDER BY a.position)
columns