Posts

Showing posts from January, 2022

Oracle: Manually clean up .patch_storage

  after running `opatch util cleanup', you can do more cleanup: --- begin quote --- Additionally, further cleanup of the $ORACLE_HOME/.patch_storage is possible if there are directories from patches applied to previous versions. This can be done manually as follows: 1.  run command: $ opatch lsinventory 2.  Remove all the sub-directories from $ORACLE_HOME/.patch_storage that are not present in the list of installed patches. Directory names would be prefaced with the patchid for example: 13343438_<timestamp> eg: >$ORACLE_HOME/OPatch/opatch lsinventory > lsinventorytxt.txt oracle-psfststdb602.tmw.com::/usr/opt/app/oracle/product/19.3.0/.patch_storage>ls -lrt total 144 drwxr-xr-x.  3 oracle dba    74 Apr 18  2019 29517242_Apr_17_2019_23_27_10 drwxr-xr-x.  3 oracle dba    74 Apr 18  2019 29585399_Apr_9_2019_19_12_47 drwxr-xr-x.  4 oracle dba    87 Jun  8  2021 32545013_Apr_16_2021_07_40_05 drwxr-x...

Oracle: Unlock schema and table stats

 SQL> exec dbms_stats.unlock_schema_stats('ORDADMIN'); PL/SQL procedure successfully completed. SQL> exec dbms_stats.gather_SCHEMA_stats('ORDADMIN'); PL/SQL procedure successfully completed. ---------- SQL> exec dbms_stats.unlock_table_stats('ORDADMIN','ORDER_HEADER'); PL/SQL procedure successfully completed. SQL> exec dbms_stats.gather_table_stats('ORDADMIN','ORDER_HEADER'); PL/SQL procedure successfully completed.

Oracle: To Tune a script

   DECLARE   l_sql_tune_task_id  VARCHAR2(100); BEGIN   l_sql_tune_task_id := DBMS_SQLTUNE.create_tuning_task (                           begin_snap  => 6996,                           end_snap    => 6997,                           sql_id      => '6zcykn22gxuhp',                           scope       => DBMS_SQLTUNE.scope_comprehensive,                           time_limit  => 60,                           task_name   => '6zcykn22gxuhp_tuning_task',               ...

DB2: To check backup status

 Two ways: (1) check the backup file, this will take long and you can control C out of it when buffers are being processed: [dev2ins2@dev601  dev2ins2] $ db2ckbkp -h WCDEV2.0.dev2ins2.DBPART000.20220124030003.001 ===================== MEDIA HEADER REACHED: =====================         Server Database Name           -- WCDEV2         Server Database Alias          -- WCDEV2         Client Database Alias          -- WCDEV2         Timestamp                      -- 20220124030003         Database Partition Number      -- 0         Instance                       -- dev2ins2         Database Configuration Type    -- 0 (Non-shar...

DB2: call a procedure

 [dev2ins2@dev601  dev2ins2] $ db2 "call WCS.UPDATE_ALT_IMAGES()"   Return Status = 0 [dev2ins2@dev601  dev2ins2] $ db2 "select count(*)  from WCS.LOG_TABLE" 1 -----------           3   1 record(s) selected. [dev2ins2@dev601  dev2ins2] Does not work in SQL Developer

DB2: to get info about a table

 select *  from syscat.tables where tabname = 'LOG_TABLE';

DB2 To get the ports / port being used

 Port numbers in use for the databases: >cat /etc/services | grep db2c 

DB2 Import data from a file

 [dev1ins1@dev601  ~] $ db2 import from /usr/opt/app/dbdump/prod-msp_list.txt of del replace into WCS.XIMAGE_TEMP SQL3109N  The utility is beginning to load data from file "/usr/opt/app/dbdump/prod-msp_list.txt". SQL3110N  The utility has completed processing.  "10820" rows were read from the input file. SQL3221W  ...Begin COMMIT WORK. Input Record Count = "10820". SQL3222W  ...COMMIT of any database changes was successful. SQL3149N  "10820" rows were processed from the input file.  "10820" rows were successfully inserted into the table.  "0" rows were rejected. Number of rows read         = 10820 Number of rows skipped      = 0 Number of rows inserted     = 10820 Number of rows updated      = 0 Number of rows rejected     = 0 Number of rows committed    = 10820 [dev1ins1@dev601  ~] $ db2 "select count(*) from WCS.XIMAGE_TEMP" 1 ----------...