Posts

Showing posts from February, 2025

Unix: to delete unix history commands

>history -c

DB2: db refresh script

 #!/bin/ksh #-----------------------------------------------------------------------------------------# #  db2.refresh.sh # #  version: 20240619035 #  #  This script performs a refresh using a backup image from production or stage #  to refresh a dev or tst database. #  #  When using this script for database WCTST3 additional steps are needed after the refresh #  that this script cannot perform because that database is part of an HADR cluster. #  #  This script will exit if it encounters a failure with a command. #  The error message will display what stage or command failed. #  The script can be run again, after correcting the failure without rerunning previously #  successful stages.  This is done by setting the stage variable to the stage where the #  script should pickup from. #  #  TO RUN: #  #    ./db2.refresh.sh  -s <source db> -t < target db> [-b <#>] [...

Postgres: tailoring GRANTS for new tables tldprod tldtran

 TLDTRAN: grant select on TAILORING.FISCAL_CALENDAR_WEEK to sp327; grant select on TAILORING.FISCAL_CALENDAR_WEEK to dpp10; grant select on TAILORING.FISCAL_CALENDAR_WEEK to my54; grant select on TAILORING.FISCAL_CALENDAR_WEEK to tailoringapp; grant select on TAILORING.FISCAL_CALENDAR_WEEK to tailoringro; grant select,insert,update,delete on TAILORING.FISCAL_CALENDAR_WEEK to pgtldadmin; grant select on TAILORING.FISCAL_CALENDAR_WEEK to postgres; TLDPROD: grant select on TAILORING.FISCAL_CALENDAR_WEEK to as317; grant select on TAILORING.FISCAL_CALENDAR_WEEK to dm508; grant select on TAILORING.FISCAL_CALENDAR_WEEK to dpp10; grant select on TAILORING.FISCAL_CALENDAR_WEEK to glh25; grant select on TAILORING.FISCAL_CALENDAR_WEEK to gr138; grant select on TAILORING.FISCAL_CALENDAR_WEEK to my54; grant select on TAILORING.FISCAL_CALENDAR_WEEK to sl253; grant select,insert,update,delete on TAILORING.FISCAL_CALENDAR_WEEK to pgtldadmin; grant select on TAILORING.FISCAL_CALENDAR_WEEK to postgr...

Oracle: To setup RMAN

 1. Connect to rmandb602 as oracle 2. create user wpstag      SQL> create user wpstag identified by bkup_123 temporary tablespace temp default tablespace  RMADMIN_DATA01 profile app_account_profile; User created.     SQL> grant create session to wpstag ;     Grant succeeded. 3.RECOVERY_CATALOG_OWNER role must be granted to user wpstag      grant RECOVERY_CATALOG_OWNER to wpstag ;      alter user wpstag quota unlimited on RMADMIN_DATA01;              grant unlimited tablespace to wpstag ;  grant select on user_db_links to wpstag;     grant execute on utl_http to wpstag; grant execute on dbms_lob to wpstag; grant execute on dbms_sql to wpstag; alter package rmadmin.dbms_rcvcat compile body; oracle-rmandb602:rmprod:/usr/opt/app/oracle/product/19.3.0/bin>rman target / catalog wpstag/bkup_123 Recovery Manager: Release 19.0.0.0.0 - Production on Mon Jan 27...

Oracle: To delete Old backup set rman

>rman target / catalog fsprod19/bkup_123@rmprod RMAN>crosscheck archivelog all; RMAN>delete noprompt expired archivelog all; RMAN>crosscheck backup; RMAN>delete expired backup; RMAN>delete obsolete; RMAN> spool log to listbackup.txt; RMAN> list backupset; RMAN> spool log off; RMAN> delete backup tag TAG20131126T084250; You can run an rman command like this to delete backups completed before a certain number of days, this example is 30 days: RMAN> DELETE FORCE NOPROMPT BACKUPSET completed before 'sysdate-30'; pp/dbdump

Postgres: check fragmentation of tables and indexes

(1)  Install the pgstattuple extension (if not already installed): show search_path;                  <-- show current schema set search_path = ctlgadmin;   <-- set schema in which to create extension CREATE EXTENSION IF NOT EXISTS pgstattuple; (2) To analyze a table for fragmentation, you can use the following command: SELECT * FROM pgstattuple('table_name'); This will return a set of statistics about the table, including the number of live and dead rows, the number of pages, and the amount of free space on each page. You can use this information to identify any fragmentation issues that may be impacting performance. (3)  To analyze an index for fragmentation, you can use the following command: SELECT * FROM pgstatindex('index_name'); This will return a set of statistics about the index, including the number of pages, the number of distinct values, and the size of the index. You can use this information to identify ...

DB2: When TSA is showing up in db2diag log

database cannot start because: $ db2start 02/21/2025 15:31:05     0   0   SQL1042C  An unexpected system error occurred. SQL1032N  No start database manager command was issued.  SQLSTATE=57019 In the db2diag log, there is: (1) 2025-02-21-11.24.31.528593-360 I13219E400            LEVEL: Event PID     : 1224844              TID : 140199623386880 PROC : db2sysc 0 INSTANCE: dev1ins1             NODE : 000 HOSTNAME: db2tst602 EDUID   : 1                    EDUNAME: db2sysc 0 FUNCTION: DB2 UDB, fast comm manager, sqkfNodeManager::initNodeManager, probe:9 DATA #1 : <preformatted> Is Cluster Manager enabled? true or false = 1 (2) 2025-02-21-11.24.32.758682-360 E15369E777            LEVEL: Error PID     : 1224844  ...

Striim notes

 Hostname: tbstriimetl601.tmw.com IP:              172.31.89.4 The following accounts all have the same pwd: keystore / sys / admin user password is str11m is it setup to autostart if server is bounced?    <-- need to ask this question on Monday https://172.31.89.4:9081  http://172.31.89.4:9080  java DB also known as Derby Since developers already have the DDL, no need to install iSpire. jdbc:db2://host-name:50000/BLUDB gk10ts19so jdbc:as400://tuxlead.tmw.com/ORCA_PROD;libraries= ORCA_PROD LEDDTA LEDWRK LEDPGM QGPL; jdbc:db2://<IP address>:<port>/<database name> jdbc:as400://neon.tmw.com:8471 172.26.18.10 / neon Port 8471 db2jcc_license_cu.jar   <-- IBM licensed jar file  jdbc:as400://HOSTNAME:PORT;   WRKSRVTBLE tuxlead is the name of the host for the leads data Port 8471 systemctl restart striim-node  to stop jdbc:postgresql://<ip address>:<port>/<database na...

Postgres: Grant on sequence

 GRANT usage, SELECT, update ON ALL SEQUENCES IN SCHEMA cpnadmin to cpnuser; GRANT usage, SELECT, update ON SEQUENCE cpnadmin.historic_offer_id_seq to cpnuser;

Postgres: To drop a user

 REASSIGN OWNED BY username TO new_owner; DROP OWNED BY username; DROP USER username; REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA ctlgadmin FROM pnm300; REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA ctlgadmin FROM pnm300; REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA ctlgadmin FROM pnm300;   REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA ctlgadmin2 FROM pnm300; REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA ctlgadmin2 FROM pnm300; REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA ctlgadmin2 FROM pnm300;  REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA ctlgadmin2 FROM pnm300; REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA ctlgadmin2 FROM pnm300; REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA ctlgadmin2 FROM pnm300;  REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA cfaudit FROM pnm300; REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA cfaudit FROM pnm300; REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA cfaudit FROM pnm300;  REVOKE ALL PRIVILEGES ON ALL TABL...

Postgres: To revoke a role

 REVOKE cloudsqlsuperuser FROM striim;

Postgres: To Retrieve list of users

 to retrieve a list of users from the pg_user table, which contains information about database users: SELECT usename AS username FROM pg_user; SELECT rolname FROM pg_roles; This query will return a list of usernames from your PostgreSQL database. If you need more details about each user, you can modify the query to include additional columns: SELECT usename AS username, usesysid AS user_id, usecreatedb AS can_create_db, usesuper AS is_superuser  FROM pg_user; SELECT usename AS role_name, CASE WHEN usesuper AND usecreatedb THEN CAST( 'superuser, create database' AS pg_catalog.text ) WHEN usesuper THEN CAST( 'superuser' AS pg_catalog.text ) WHEN usecreatedb THEN CAST( 'create database' AS pg_catalog.text ) ELSE CAST( '' AS pg_catalog.text ) END role_attributes FROM pg_catalog.pg_user ORDER BY role_name desc ;