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
SET SERVEROUTPUT ON; | |
DECLARE | |
job_name VARCHAR2(30); | |
cpu_count NUMBER; | |
loop_iterations NUMBER := 500000000; | |
start_snap_id NUMBER; | |
end_snap_id NUMBER; | |
job_running NUMBER; |
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 FUNCTION pg_temp.get_rows(p_schemaname text, p_tablename text) | |
RETURNS bigint AS $$ | |
DECLARE | |
result_rowcount bigint; | |
BEGIN | |
EXECUTE format('SELECT COUNT(*) FROM "%I"."%I"', p_schemaname, p_tablename) | |
INTO result_rowcount; | |
RETURN result_rowcount; | |
END; | |
$$ LANGUAGE plpgsql; |
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> set autotrace traceonly statistics | |
SQL>select | |
owner, | |
table_name, | |
XMLCAST( | |
XMLQUERY( | |
'/ROWSET/ROW/NUMROWS' PASSING DBMS_XMLGEN.GETXMLTYPE( | |
'select count(*) NUMROWS | |
from ' || '"' || OWNER || '". "' || TABLE_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
SQL> set autotrace traceonly statistics | |
SQL> WITH function get_rows( | |
p_owner in varchar2, p_tablename in varchar2 | |
) return number as result_rowcount number default NULL; | |
begin execute immediate 'select count(*) | |
from ' || '"' || p_owner || '"."' || p_tablename || '"' INTO result_rowcount; | |
return result_rowcount; | |
end; | |
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
import psycopg2 | |
import select | |
from datetime import datetime | |
import subprocess | |
import logging | |
import time | |
#Configure logging | |
logging.basicConfig( | |
filename='/var/log/postgresql_email_listener/postgresql_email_listener.log', |
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 gvs.inst_id,DECODE (request, 0, 'Holder: ', 'waiter:') || gvl.sid sess, | |
status, | |
id1, | |
id2, | |
lmode, | |
request, | |
gvl.TYPE | |
FROM gv$lock gvl, gv$session gvs | |
WHERE (id1, id2, gvl.TYPE) IN (SELECT id1, id2, TYPE | |
FROM gv$lock |
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 sql_id, | |
sum(invalidations) | |
FROM gv$sql | |
WHERE invalidations > 0 | |
GROUP BY sql_id | |
ORDER BY sum(invalidations) desc | |
FETCH first 20 ROWS only ; |
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
#!/bin/bash | |
# Set Oracle environment variables | |
source /home/oracle/.bashrc | |
export ORAENV_ASK=NO | |
export ORACLE_SID=bltdb1 | |
. oraenv bltdb1 | |
#export ORACLE_PDB_SID=testpdb | |
# Execute SQL query and spool output to file |
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 query to generate JSON output | |
SPOOL audit.log APPEND | |
SELECT '{ "oracle_audit": ' || | |
json_object( | |
'AUDIT_TYPE' VALUE AUDIT_TYPE, | |
'SESSIONID' VALUE SESSIONID, | |
'OS_USERNAME' VALUE OS_USERNAME, | |
'USERHOST' VALUE USERHOST, | |
'TERMINAL' VALUE TERMINAL, |
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 | |
username, | |
guessed_password, | |
stored_hashed_pwd, | |
CASE | |
WHEN stored_hashed_pwd = computed_hashed_pwd THEN 'Y' | |
ELSE 'N' | |
END AS result | |
FROM ( -- This SELECT concatenates the salt with the guessed password and hashes it. | |
SELECT |
NewerOlder