a-z
, A-Z
and 0-9
characters (source)CREATE OR REPLACE TRIGGER triggerName after startup on database DECLARE (declare SQL variables here) BEGIN (trigger code here) END; /
set long 100000
select dbms_metadata.get_ddl('TRIGGER','TRIGGERNAME',USER) from dual;
OR :
select text from user_source where name='TRIGGERNAME' and type='TRIGGER';
TRIGGERNAME must be uppercase !
drop trigger triggerName;
Trigger dropped.
$ORACLE_SID:$ORACLE_HOME:[N|Y]:
entries (details)ORACLE_SID=value
ls -l $ORACLE_HOME/dbs/{init,spfile}$ORACLE_SID.ora $ORACLE_HOME/dbs/orapw$ORACLE_SID $ORACLE_HOME/network/admin/{listener,tnsnames}.ora
SET pagesize 50 SET linesize 200 column OWNER format a15 column DIRECTORY_NAME format a30 column DIRECTORY_PATH format a50 select * from dba_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH ------- ------------------------------- -------------------------------------------------- SYS DATAPUM_PATH /appli/oracle/ORACLE_SID/oraarch SYS EXPORACLE_SIDPARALLEL /sauvebase/ORACLE_SID/20140620 SYS EXPORACLE_SID /sauvebase/ORACLE_SID/EXPORACLE_SID SYS EXPORTBASE /exportbase SYS REP_MDP /outillage/controle/c_oracle/sql SYS DIRECTORY_PATH /sauvebase/ORACLE_SID SYS SAUVE_BASE_ORACLE_SID /sauvebase/ORACLE_SID SYS sauvebase_ORACLE_SID /sauvebase/ORACLE_SID SYS exportbase /exportbase SYS DATA_PUMP_DIR /appli/oracle/ORACLE_SID SYS EXPDP_DIR /exportbase SYS DIR_ALR_DEPOT /appli/vdp/work/donnees/donnees_de_reference/ SYS ORACLE_OCM_CONFIG_DIR /logiciels/oracle/oradb/11.2.0/ora/ccr/state
ORACLE_SID
environment variable must be setexpdp \"/ as sysdba\" SCHEMAS=mySchema DIRECTORY=DATA_PUMP_DIR DUMPFILE=expdp_MYSCHEMA_YYYYMMDD.dmp LOGFILE=expdp_MYSCHEMA_YYYYMMDD.log
The DIRECTORY option expects a directory alias, not a filesystem path.
This is a WIP about the checks to perform when something's running wrong with Oracle. Only very basic stuff so far...
export ORACLE_SID=ORACLE_SID; sqlplus -s / as sysdba << EOSQL
select value || '/alert_$ORACLE_SID.log' as alertLog from v\$parameter where name='background_dump_dest';
select value as traceFile from v\$diag_info where name='Default Trace File';
EOSQL
select database_role from v$database;
' | sqlplus -s / as sysdbaDATABASE_ROLE ------------------------------------------------ PRIMARYor :
DATABASE_ROLE ------------------------------------------------ PHYSICAL STANDBYOther "standby" modes exist, but the one I expect is PHYSICAL STANDBY (these other modes are not used in my company) Anyway, if this returns an error, this _may_ indicate the Data Guard configuration is broken.
select * from v$archive_gap;
' | sqlplus -s / as sysdbano rows selected
export ORACLE_SID=ORACLE_SID; grep 'control_files' /home/oracle/admin/$ORACLE_SID/dbs/init$ORACLE_SID.ora | sed -r "s_.*='([^\']*\.ctl)','([^\']*\.ctl)','([^\']*\.ctl)'_\1 \2 \3_g" | xargs ls -lh
-rw-r----- 1 oracle oinstall 14M Oct 29 10:01 /appli/oracle/ORACLE_SID/oractl01/ORACLE_SID_ctrl01.ctl -rw-r----- 1 oracle oinstall 14M Oct 29 10:01 /appli/oracle/ORACLE_SID/oractl02/ORACLE_SID_ctrl02.ctl -rw-r----- 1 oracle oinstall 14M Oct 29 10:01 /appli/oracle/ORACLE_SID/oradata01/ORACLE_SID_ctrl03.ctl
Oracle tracks its internal parameters in these files. So this is normal their modification time is always incrementing.
NAME TYPE VALUE ------------------------------- --------------- ------------------------------ dg_broker_config_file1 string /logiciels/oracle/oradb/11.2.0/ora/dbs/dr1ORACLE_SID_primaryDatacenter.dat dg_broker_config_file2 string /logiciels/oracle/oradb/11.2.0/ora/dbs/dr2ORACLE_SID_primaryDatacenter.dat dg_broker_start boolean FALSE
select (columns) from myTable where (condition)
query works like a charm whereas update theSameTable set (values) where (theSameCondition)
never returns to the prompt/dev/mapper/y6luvg_pco01-lv_oraarch_pco 50G 47G 147M 100% /appli/oracle/ORACLE_SID/oraarch
Ok, now you know.
Read about this alternate solution, which looks both safer and more efficient than the one below .
As said above, this is highly experimental and should be used at your own risk.
using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=258 device type=DISK RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1995_1.arc thread=1 sequence=1995 RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_3088_1.arc thread=1 sequence=3088 List of Archived Log Copies for database with db_unique_name ORACLE_SID_STANDBYDATACENTER ===================================================================== Key Thrd Seq S Low Time ------- ---- ------- - --------- 1 1 1605 A 21-APR-15 Name: /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1605_1.arc 2 1 1606 A 21-APR-15 Name: /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1606_1.arc 462 1 1970 A 25-JUN-15 Name: /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1970_1.arc 463 1 1971 A 25-JUN-15 Name: /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1971_1.arc Do you really want to delete the above objects (enter YES or NO)?And if you say yes :
deleted archived log archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1969_1.arc RECID=461 STAMP=884965649 deleted archived log archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1970_1.arc RECID=462 STAMP=884965650 deleted archived log archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1971_1.arc RECID=463 STAMP=884965650 Deleted 3 objects RMAN-06207: WARNING: 364 objects could not be deleted for DISK channel(s) due RMAN-06208: to mismatched status. Use CROSSCHECK command to fix status RMAN-06210: List of Mismatched objects RMAN-06211: ========================== RMAN-06212: Object Type Filename/Handle RMAN-06213: --------------- --------------------------------------------------- RMAN-06214: Archivelog /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1605_1.arc RMAN-06214: Archivelog /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1606_1.arc RMAN-06214: Archivelog /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1967_1.arc RMAN-06214: Archivelog /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1968_1.arc
Filesystem Size Used Avail Use% Mounted on /dev/mapper/y6luvg_pco01-lv_oraarch_pco 50G 43G 297M 99% /appli/oracle/ORACLE_SID/oraarch297MB freed is way not enough. We'll have to be a little more evil...
Filesystem Size Used Avail Use% Mounted on /dev/mapper/y6luvg_pco01-lv_oraarch_pco 50G 43G 4.4G 91% /appli/oracle/ORACLE_SID/oraarchLooks better.
using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=258 device type=DISK validation failed for archived log archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1605_1.arc RECID=1 STAMP=877639635 validation failed for archived log archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1606_1.arc RECID=2 STAMP=877639637 validation succeeded for archived log archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_3387_1.arc RECID=803 STAMP=888848753 validation succeeded for archived log archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_3447_1.arc RECID=804 STAMP=888849107 Crosschecked 774 objects
released channel: ORA_DISK_1 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=258 device type=DISK List of Archived Log Copies for database with db_unique_name ORACLE_SID_STANDBYDATACENTER ===================================================================== Key Thrd Seq S Low Time ------- ---- ------- - --------- 1 1 1605 X 21-APR-15 Name: /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1605_1.arc 2 1 1606 X 21-APR-15 Name: /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1606_1.arc 498 1 3082 X 27-JUL-15 Name: /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_3082_1.arc 499 1 3083 X 27-JUL-15 Name: /appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_3083_1.arc deleted archived log archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1605_1.arc RECID=1 STAMP=877639635 deleted archived log archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_1606_1.arc RECID=2 STAMP=877639637 deleted archived log archived log file name=/appli/oracle/ORACLE_SID/oraarch/ORACLE_SID_875897971_3083_1.arc RECID=499 STAMP=886148904 Deleted 469 EXPIRED objects
After that, I've been able to use the database again
shutdown immediate;\nstartup mount;
' | sqlplus -s / as sysdba; echo 'delete noprompt archivelog all;
' | rman target /shutdown immediate;\nstartup mount;
' | sqlplus -s / as sysdba; echo -e 'backup archivelog all not backed up 1 times;\nbackup archivelog all delete input;
' | rman target /DELETE NOPROMPT ARCHIVELOG UNTIL TIME='SYSDATE-2'
" | rman target /as root : cp /home/oracle/app/oracle/product/12.1.0/dbhome_1/bin/db{start,shut} /etc/init.d chown root:root /etc/init.d/db{start,shut} update-rc.d dbstart defaults insserv: warning: script 'K01dbstart' missing LSB tags and overrides insserv: warning: script 'dbstart' missing LSB tags and overrides insserv: warning: script 'dbshut' missing LSB tags and overrides (but returns a success) USAGE : > /u01/app/oracle/product/12.1.0/dbhome_1/shutdown.log > /u01/app/oracle/product/12.1.0/dbhome_1/startup.log /etc/init.d/dbstart /u01/app/oracle/product/12.1.0/dbhome_1/ /etc/init.d/dbshut /u01/app/oracle/product/12.1.0/dbhome_1/ ==> log is full of errors Other solution : create /etc/init.d/oracle as follows (+chmod 755)
#!/usr/bin/env bash ######################################### /etc/init.d/oracle ######################################## # chkconfig: 235 80 20 # description: ajout de service auto pour start/stop oracle ########################################## ########################################################## ORACLE_OWNER=oracle ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1/ lockFile='/var/lock/subsys/oracle' case $1 in start) echo -n "Démarrage Oracle DB:" su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" touch "$lockFile" ;; stop) echo -n "Arrêt Oracle DB:" su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" rm "$lockFile" ;; *) echo "Usage: $0 {start|stop}" ;; esac
I hear and I forget.here are my notes on experimenting with Oracle :
I see and I remember.
I do and I understand.
NAMES.DIRECTORY_PATH=(TNSNAMES, EZCONNECT)Create it as oracle with : echo "NAMES.DIRECTORY_PATH=(TNSNAMES, EZCONNECT)" > $ORACLE_HOME/network/admin/sqlnet.ora
select ( (select value from v$nls_parameters where parameter='NLS_LANGUAGE') || '_' || (select value from v$nls_parameters where parameter='NLS_TERRITORY') || '.' || (select value from v$nls_parameters where parameter='NLS_CHARACTERSET') ) as NLS_LANG FROM dual;
CURRENT_USER CURRENT_SCHEMA --------------- -------------------- USERNAME (matching schema)
=
in Oracle passwords. Such passwords work fine when used interactively. BUT they become unusable in one-liners, where it seems the equal sign is interpreted as trying to set a variable :
Not shown here, but I've also tried to single-quote the password : no change, double-quote : no change, escape the =
with a \
: no change, quote + escape : no change, ...
Invalid option. WTF?!?
Syntax:
CONNECT <username>/<password>[@<connect identifier>]
ORA-01017: invalid username/password; logon denied At least the password has been received, even if it's wrong.
Avoid the equal sign =
in passwords.
this is highly experimental and DOES NEED some extra work. Don't rely on this so far
SELECT dbms_metadata.get_ddl('USER', username) || '/' usercreate FROM dba_users WHERE username='SYS';USERCREATE
--------------------------------------------------------------------------------
ALTER USER "SYS" IDENTIFIED BY VALUES 'S:E1B705DFFFAB28F
B511B87C251B62A2276D
alter user SYS identified by PASSWORD;
%Oracle Database Vault%
';PARAMETER VALUE
----------------------- ----------
Oracle Database Vault TRUE TRUE
= enabled
select value || '/alert_$ORACLE_SID.log' as alertLog from v\$parameter where name='background_dump_dest';
" | sqlplus -s / as sysdba