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 S.USERNAME || '(' || s.sid || ')-' || s.osuser UNAME, | |
s.program || '-' || s.terminal || '(' || s.machine || ')' PROG, | |
s.sid || '/' || s.serial# sid, | |
s.status "Status", | |
p.spid, | |
sql_text sqltext | |
FROM v$sqltext_with_newlines t, V$SESSION s, v$process p | |
WHERE t.address = s.sql_address | |
AND p.addr = s.paddr(+) | |
AND t.hash_value = s.sql_hash_value |
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 ss.username, se.SID, VALUE / 100 cpu_usage_seconds | |
FROM v$session ss, v$sesstat se, v$statname sn | |
WHERE se.STATISTIC# = sn.STATISTIC# | |
AND NAME LIKE '%CPU used by this session%' | |
AND se.SID = ss.SID | |
AND ss.status = 'ACTIVE' | |
AND ss.username IS NOT NULL | |
ORDER BY VALUE DESC; |
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 a.sid, | |
a.serial#, | |
b.username, | |
opname OPERATION, | |
target OBJECT, | |
TRUNC (elapsed_seconds, 5) "ET (s)", | |
TO_CHAR (start_time, 'HH24:MI:SS') start_time, | |
ROUND ( (sofar / totalwork) * 100, 2) "COMPLETE (%)" | |
FROM v$session_longops a, v$session b | |
WHERE a.sid = b.sid |
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 * | |
FROM ( SELECT ROWNUM, | |
SUBSTR (a.sql_text, 1, 200) sql_text, | |
TRUNC ( | |
a.disk_reads / DECODE (a.executions, 0, 1, a.executions)) | |
reads_per_execution, | |
a.buffer_gets, | |
a.disk_reads, | |
a.executions, | |
a.sorts, |
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 program application, COUNT (program) Numero_Sesiones | |
FROM v$session | |
GROUP BY program | |
ORDER BY Numero_Sesiones DESC; |
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
--search a string foo_something in package source code | |
SELECT * | |
FROM dba_source | |
WHERE UPPER (text) LIKE '%FOO_SOMETHING%' | |
AND owner = 'USER_NAME'; |
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
--generate random number between 0 and 100 | |
SELECT ROUND (DBMS_RANDOM.VALUE () * 100) + 1 AS random_num FROM DUAL; |
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
File dir = new File("directoryName"); | |
String[] children = dir.list(); | |
if (children == null) { | |
// Either dir does not exist or is not a directory | |
} else { | |
for (int i=0; i < children.length; i++) { | |
// Get filename of file or directory | |
String filename = children[i]; | |
} | |
} |
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
public class BytesToString { | |
public static String bytes2String(byte[] bytes) { | |
StringBuilder sb = new StringBuilder(); | |
for (byte b : bytes) { | |
sb.append(String.format("%02X ", b).trim()); | |
} | |
return sb.toString(); |
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
public class CharFormatConverter { | |
static byte[] ASCII2EBCDIC = new byte[256]; | |
static byte[] EBCDIC2ASCII = new byte[256]; | |
static { | |
ASCII2EBCDIC[0x00] = (byte) 0x00; | |
ASCII2EBCDIC[0x01] = (byte) 0x01; | |
ASCII2EBCDIC[0x02] = (byte) 0x02; | |
ASCII2EBCDIC[0x03] = (byte) 0x03; | |
ASCII2EBCDIC[0x04] = (byte) 0x37; | |
ASCII2EBCDIC[0x05] = (byte) 0x2D; |