Posts

Showing posts from May, 2025

DB2: memory

 db2 list db directory db2 get dbm cfg | grep -i instance exit db2 update dbm cfg using INSTANCE_MEMORY 1572864 immediate db2 terminate; db2 force applications all; db2stop force; db2start free -m db2 get dbm cfg | grep instance Configuring memory and memory heaps - IBM Documentation https://www.ibm.com/docs/en/db2/11.5.x?topic=overview-configuring-memory-memory-heaps a single parameter, instance_memory, to specify all of the memory that the database manager is allowed to allocate from its private and shared the db2mtrk command to monitor heap usage and the ADMIN_GET_MEM_USAGE table function to query overall memory consumption >db2mtrk  -a Note: The DBMCFG and DBCFG administrative views retrieve database manager configuration parameter information for the currently connected database for all database partitions. For the mon_heap_sz, stmtheap, and stat_heap_sz configuration parameters, the DEFERRED_VALUE column on this view does not persist across database activations. That ...

MySQL: To find the character set and collation

  SELECT SCHEMA_NAME AS `Database`, DEFAULT_CHARACTER_SET_NAME AS ` Character Set `, DEFAULT_COLLATION_NAME AS ` Collation ` FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = DATABASE(); wp_db        utf8mb4        utf8mb4_bin

MySQL: To create a database

 To create a database in MySQL, you can use the CREATE DATABASE statement. Here's an example: CREATE DATABASE my_database; Explanation: CREATE DATABASE is the command to create a new database. my_database is the name of the database you're creating. You can replace it with your desired name. Additional Notes: Check Existing Databases: To ensure the database name doesn't already exist, you can list all databases: SHOW DATABASES; Use the Database: After creating the database, you can select it for use: USE my_database; Optional Parameters: You can specify additional options like character set and collation: CREATE DATABASE my_database CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Postgres: To check the locale / Character set settings

  To check the locale settings in PostgreSQL, you can use the following SQL query: SHOW lc_collate; SHOW lc_ctype; SHOW lc_messages; SHOW lc_monetary; SHOW lc_numeric; SHOW lc_time; Explanation: lc_collate : Defines the collation order (sorting rules) for strings. lc_ctype : Specifies the character classification (e.g., upper/lower case). lc_messages : Determines the language for system messages. lc_monetary : Sets the locale for monetary formatting. lc_numeric : Configures the locale for numeric formatting. lc_time : Specifies the locale for date and time formatting. You can run these commands in your PostgreSQL client (e.g., psql ) to view the current locale settings. If you need to change them, you can configure them in the postgresql.conf file or during database initialization.

Postgres: To Drop constraint

 ALTER TABLE ordadmin.email_template DROP CONSTRAINT email_template_pk cascade;

Postgres: To change timezone

https://cloud.google.com/sql/docs/postgres/flags#troubleshooting-flags Troubleshooting Issue Troubleshooting You set the time zone for a session, but it expires when you log off. Connect to the database and set the database time zone to the one you want, either per user or per database. In Cloud SQL for PostgreSQL, you can specify the following. These settings remain after a session is closed, mimicking a  .conf  configuration: ALTER DATABASE dbname SET TIMEZONE TO ' timezone ' ; ALTER USER username SET TIMEZONE TO ' timezone ' ; These settings apply only to new connections to the database. To see the change to the time zone, disconnect from the instance and then reconnect to it.

Postgres: To change owner of table

 ALTER TABLE ordadmin.email_template OWNER TO ordadmin; ALTER TABLE table_name OWNER TO new_owner;

Postgres: To list table owners

SELECT schemaname, tablename, tableowner FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema') ORDER BY tableowner, schemaname, tablename;

Postgres: list of constraints along with their owners

  Here is a PostgreSQL SQL query to retrieve a list of constraints along with their owners: Copy the code SELECT conname AS constraint_name, conrelid::regclass AS table_name, pg_catalog.pg_get_userbyid(pg_class.relowner) AS owner FROM pg_constraint JOIN pg_class ON conrelid = pg_class.oid WHERE contype IN ( 'p' , 'u' , 'f' , 'c' ) -- p: primary key, u: unique, f: foreign key, c: check ORDER BY table_name, constraint_name; Explanation: pg_constraint : Contains information about constraints. pg_class : Provides details about tables and their owners. pg_get_userbyid(pg_class.relowner) : Fetches the owner of the table associated with the constraint. contype : Filters constraints by type: p : Primary Key u : Unique f : Foreign Key c : Check Constraint This query will give you a clear list of constraints, the tables they belong to, and their respective owners.

MySQL: To see connections to the database

use  wp_db; -- see the currently open connections  details SHOW PROCESSLIST; --  to see the number of currently open connections: SHOW STATUS WHERE `variable_name` = 'Threads_connected'; -- mysqladmin utility to get a short status message from the MySQL server: mysqladmin status -u root -p

MySQL: set schema set database

 USE database_name; for example:- user wp_db;

WIN: reboot windows 10 desktop remotely cmd window

 Microsoft Windows [Version 10.0.19045.5487] (c) Microsoft Corporation. All rights reserved. H:\>shutdown /r /m \\172.27.240.14 /t 0 H:\>shutdown /r /m \\1099isp201118d /t 0 1099isp201118d: The entered computer name is not valid or remote shutdown is not supported on the target computer. Check the name and then try again or contact your system administrator.(53) /r: Specifies that the computer should be restarted.  /m \\computername: Specifies the remote computer to be restarted, replacing computername with the actual name of the remote machine.  /t 0: Sets the timeout to zero, meaning the restart will occur immediately.  If you need to use an IP address instead of a computer name, replace \\computername with the IP address (e.g., \\192.168.1.100).

Unix: Centrify status and restart

 [root@db2tst601 etc]# systemctl status sssd.service ● sssd.service - System Security Services Daemon    Loaded: loaded (/usr/lib/systemd/system/sssd.service; enabled; vendor preset: enabled)    Active: failed (Result: exit-code) since Fri 2025-05-16 00:31:55 CDT; 4h 0min ago   Process: 53976 ExecStart=/usr/sbin/sssd -i ${DEBUG_LOGGER} (code=exited, status=1/FAILURE)  Main PID: 53976 (code=exited, status=1/FAILURE) May 16 00:31:12 db2tst601 sssd[53976]: Child [54045] ('TMW.COM':'%BE_TMW.COM') was terminated by own WATCHDOG. Consult corresponding logs to figure out the reason. May 16 00:31:13 db2tst601 sssd_be[1001039]: Starting up May 16 00:31:14 db2tst601 sssd_nss[1001041]: Starting up May 16 00:31:18 db2tst601 sssd_nss[1001077]: Starting up May 16 00:31:18 db2tst601 sssd[53976]: Exiting the SSSD. Could not restart critical service [nss]. May 16 00:31:42 db2tst601 sssd_be[1001039]: Shutting down (status = 0) May 16 00:31:43 db2tst601 sssd_pam[2311680]...

Postgres: To add new developer to coupon test

 create role tb_s; grant tb_s to pkm481; CREATE ROLE  pkm481 LOGIN PASSWORD 'tempPwd_2'; GRANT CONNECT ON DATABASE cpntest TO pkm481; GRANT usage ON SCHEMA cpnadmin TO pkm481; GRANT select,insert,update,delete ON all tables in SCHEMA cpnadmin TO pkm481;

Postgres: View Check Role Privileges for a user

 SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication FROM pg_roles WHERE rolname = 'pkm481';

Postgres: view Object-Level Privileges for a user

 SELECT grantee, privilege_type, table_schema, table_name FROM information_schema.role_table_grants WHERE grantee = 'pkm481';

Postgres: View schema privileges for user

  SELECT r . usename AS grantor , e . usename AS grantee , nspname , privilege_type , is_grantable FROM pg_namespace JOIN LATERAL ( SELECT * FROM aclexplode (nspacl) AS x) a ON true JOIN pg_user e ON a . grantee = e . usesysid JOIN pg_user r ON a . grantor = r . usesysid WHERE e . usename = 'eisadmin' ;

Postgres: View table privilege for user

  SELECT * FROM information_schema . role_table_grants WHERE grantee = 'eisadmin' ;

DB2: To get privileges for a table

 SELECT      GRANTOR,      GRANTEE FROM      SYSCAT.TABAUTH  WHERE      TABSCHEMA = 'WCS'      AND TABNAME = 'XTMW_CONSTRUCTOR'; Or  to see all the privileges  SELECT  * FROM      SYSCAT.TABAUTH  WHERE      TABSCHEMA = 'WCS'      AND TABNAME = 'XTMW_CONSTRUCTOR';

DB2 : displays the list of active utilities

  db2 list utilities show detail The  LIST UTILITIES  command in DB2 displays the list of active utilities on the instance, providing detailed progress information for utilities that support progress monitoring. This command is useful for monitoring the status of running utilities, such as online backups or RUNSTATS operations. It helps in identifying performance issues and determining which utilities are running. If a utility is suspected to be degrading performance, it can be throttled using the  SET UTIL_IMPACT_PRIORITY  command. Note : The  LIST UTILITIES  command can also be used to monitor the progress of deferred cleanup of indexes by asynchronous index cleanup and the completion of a detach of a data partition from a partitioned table. Sample Output ID = 1 Type = BACKUP Database Name = SAMPLE Description = offline db Start Time = 09/17/2012 13:28:30.575198 State = Executing Invocation Type = User Throttling: Priority = Unthrottled Progress...

DB2: Get rollforward status

 db2 rollforward db WCPRDI query status

Oracle : Restore script for HRTEST

Run PT_CONFIG_TABLE_EXP.DMS to capture tools tables from target environment - hrtest From HRPROD: >rman target / catalog hrprod19/bkup_123@rmprod auxiliary sys/cZQwV3EqQy9K_M@hrtest RMAN> spool log to /usr/local/oracle/restorehrtestMay2nd.txt; RMAN> run { startup clone nomount; allocate auxiliary channel aux1 device type disk; set until scn 125141640077; DUPLICATE target database to hrtest  nofilenamecheck db_file_name_convert = ( 'hrprod','hrtest' ); } spool log off On HRPROD: oracle-pshrdb602.tmw.com:hrprod:/usr/opt/app/oracle/orahome>rman target / catalog hrprod19/bkup_123@rmprod Recovery Manager: Release 19.0.0.0.0 - Production on Fri Jun 20 10:18:21 2025 Version 19.27.0.0.0 Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved. connected to target database: HRPROD (DBID=3518093084) connected to recovery catalog database RMAN> list backup of controlfile completed before '21-JUN-2025'; list backup of controlfile completed...