Posts

Oracle: Purge recyclebin

 >sqlplus schema_name/password SQL*Plus: Release 12.1.0.2.0 Production on Tue Dec 7 14:52:44 2021 Copyright (c) 1982, 2014, Oracle.  All rights reserved. Last Successful login time: Tue Dec 07 2021 14:52:41 -06:00 Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production SQL> purge recyclebin; Recyclebin purged.

Oracle: To find oldest date in a table

 SELECT MIN(D_TIMESTAMP) FROM drmadmin.RM_TRANSACTION_HISTORY;

DB2: To check table status in the event of SQLCODE=-668, SQLSTATE=57007

  To check table's status ('C' means that the table is in set integrity pending) db2 "select status from syscat.tables where tabname = 'COLLDESC'" To set integrity db2 "set integrity for wcs.colldesc immediate checked"

DB2: Offline backup

-- To bring down the database  $ db2 force application all; db2stop -- To deactivate the database [dev1ins1@dev601  dev1ins1] $ db2 deactivate db wcdev1 -- To verify there are no applications [db2admin@dev601 dev1ins1 gm15] $ db2 list applications    SQL1611W  No data was returned by Database System Monitor. -- To connect to the database [dev1ins1@dev601  dev1ins1] $ db2start -- To kick off the backup [db2admin@dev601 dev1ins1 gm15] $ /usr/local/db2/admin_scripts/db2.backup_db.ksh -i dev1ins1 -d wcdev1 -o Actual backup command in script: db2.backup_db.ksh db2 backup database "$database" to "$backup_dir" compress without prompting 

Oracle: To see the entire date field

 TO_CHAR(datecol, 'DD-MON-YYYY HH:MI:SS') update       odsadmin.ods_uv_co set       opening_physical =  to_date('01-JAN-1990','DD-MON-YYYY') where       store_srcnum in (9099,0000,0001,0002,0047,0995,0104,0927) /

Oracle: Change AWR snapshot interval and retention

 SQL> execute dbms_workload_repository.modify_snapshot_settings (interval => 10, retention => 20160); PL/SQL procedure successfully completed. 10 mins and 14 days in mins: execute dbms_workload_repository.modify_snapshot_settings ( interval => 60,  retention => 1576800);    <-- 3 years in minutes To get the current settings: select        extract( day from snap_interval) *24*60+        extract( hour from snap_interval) *60+        extract( minute from snap_interval ) "Snapshot Interval",        extract( day from retention) *24*60+        extract( hour from retention) *60+        extract( minute from retention ) "Retention Interval" from dba_hist_wr_control;

DB2: To grant a role to a user

 db2 grant connect on database to user  username ;  db2 grant role db2read  to user username ;