select trim( substr(file_name, (instr(file_name,'/', -1, 1) +1) ) ) "file name" from dba_data_files;Result:
file name |
---|
system01.dbf |
sysaux01.dbf |
undotbs01.dbf |
users01.dbf |
appl_data.dbf |
Minimalistic Oracle contains a collection of practical examples from my encounters with Oracle technologies. When relevant, I also write about other technologies, like Linux or PostgreSQL. Many of the posts starts with "how to" since they derive directly from my own personal experience. My goal is to provide simple examples, so that they can be easily adapted to other situations.
select trim( substr(file_name, (instr(file_name,'/', -1, 1) +1) ) ) "file name" from dba_data_files;Result:
file name |
---|
system01.dbf |
sysaux01.dbf |
undotbs01.dbf |
users01.dbf |
appl_data.dbf |
exec dbms_application_info.set_client_info('Step one.'); exec dbms_application_info.set_module('module1','gettrades');
select SID,SERIAL#,SQL_ID,STATUS,osuser,machine,schemaname,MODULE,ACTION,CLIENT_INFO,LOGON_TIME,EVENT,STATE,FINAL_BLOCKING_SESSION "blocking" from v$session WHERE schemaname='SALES' AND STATUS='ACTIVE' UNION select SID,SERIAL#,SQL_ID,STATUS,osuser,machine,schemaname,MODULE,ACTION,CLIENT_INFO,LOGON_TIME,EVENT,STATE,FINAL_BLOCKING_SESSION "blocking" from v$session where SID = (SELECT FINAL_BLOCKING_SESSION FROM V$SESSION WHERE schemaname='SALES' AND STATUS='ACTIVE');
SID | SERIAL# | SQL_ID | STATUS | OSUSER | MACHINE | SCHEMANAME | MODULE | ACTION | CLIENT_INFO | LOGON_TIME | EVENT | STATE | blocking |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
32 | 4759 | 5jg1839cyxzgh | ACTIVE | oracle | mytestserver.com | SALES | DELETE MODULE | DELETE_SCHEMA | Delete XSD. | 15.02.2018 12:04:43 | library cache lock | WAITING | 2285 |
2285 | 48625 | g3bc37vx8fy3u | INACTIVE | JIM | COMPANY\PC-157 | SALES | SQL*Plus | 14.02.2018 14:08:57 | SQL*Net message from client | WAITING | NULL |
select dbtimezone from dual;
DBTIME |
---|
+02:00 |
select sysdate, systimestamp, current_date,current_timestamp(5), localtimestamp(3) from dual
SYSDATE | SYSTIMESTAMP | CURRENT_DATE | CURRENTTIMESTAMP | LOCALTIMESTAMP |
---|---|---|---|---|
13.07.2016 11:45:52 | 13.07.2016 11.45.52,597707 +02:00 | 13.07.2016 11:45:52 | 13.07.2016 11.45.52,59771 +02:00 | 13.07.2016 11.45.52,598 |
alter session set time_zone='America/New_York'; Session altered.
select sysdate, systimestamp, current_date,current_timestamp(5), localtimestamp(3) from dual;
SYSDATE | SYSTIMESTAMP | CURRENT_DATE | CURRENTTIMESTAMP | LOCALTIMESTAMP |
---|---|---|---|---|
13.07.2016 11:49:15 | 13.07.2016 11.49.15,381888 +02:00 | 13.07.2016 05:49:15 | 13.07.2016 05.49.15,38189 AMERICA/NEW_YORK | 13.07.2016 05.49.15,382 |
tnsping mydb
OK (10 msec)
TNS-03505: Failed to resolve name
REMOTE_LSNR_STATUS=`cat ${LOG_DIR}/test_tnsping.log | egrep -e 'TNS-|OK' | awk -F '[-(]' '{ print $1 }'`
CREATE OR REPLACE FUNCTION LIST_FILES( p_directory IN VARCHAR2, p_file_pattern IN VARCHAR2 default null) RETURN file_array pipelined AS l_path VARCHAR2(1024); l_dummy VARCHAR2(1024); BEGIN SELECT directory_path INTO l_path FROM all_directories WHERE directory_name = p_directory; sys.DBMS_BACKUP_RESTORE.SEARCHFILES(l_path, l_dummy); FOR file_list IN (SELECT FNAME_KRBMSFT AS file_name FROM X$KRBMSFT WHERE FNAME_KRBMSFT LIKE '%'|| NVL(p_file_pattern, FNAME_KRBMSFT)||'%' ) LOOP PIPE ROW(file_list.file_name); END LOOP; END; /
SELECT * FROM TABLE(LIST_FILES('MY_DIR','%*.dmp%'));
connect scott/tiger var leom char(10); var eod char(10); exec :leom := to_date('30.09.2013','DD.MM.YYYY'); exec :eod := to_date('31.10.2013','DD.MM.YYYY'); SELECT col1, col2 ....col n FROM TABLE1 WHERE START_DATE <= :eod AND END_DATE <= :leom;