Posts

Showing posts from August, 2025

MySQL: drop user

  DROP USER 'username' @ 'hostname' ; drop user 'root'@'%';

Postgres: To see which flags are turned on

Image
  select * FROM pg_settings where name like '%integration%' ; SHOW parameter_name; example: SHOW log_statement; SHOW ALL ; To see parameters that require a restart: SELECT name, setting FROM pg_settings WHERE pending_restart = true ;

DB2: object types

  SYSCAT.INDEXES  for indexes. SYSCAT.TRIGGERS  for triggers. SYSCAT.ROUTINES  for stored procedures and functions. SYSCAT.TABLES for tables SELECT TABNAME AS OBJECT_NAME, TABSCHEMA AS SCHEMA_NAME, TYPE AS OBJECT_TYPE FROM SYSCAT.TABLES WHERE TABNAME = 'YOUR_OBJECT_NAME' ; SELECT * FROM SYSCAT.tables where tabschema='WCS' order by tabname; SELECT * FROM SYSCAT.ROUTINES where routineschema='WCS' order by routinename; SELECT * FROM SYSCAT.INDEXES where INDschema='WCS' order by INDname; SELECT * FROM SYSCAT.TRIGGERS where trigschema='WCS' order by trigname;

Db2: To list schemas and when created

   select     create_time, schemaname as schema_name,     owner as schema_owner,     case ownertype          when 'S' then 'system'         when 'U' then 'individual user'      end as schema_owner_type,     definer as schema_definer,     case definertype          when 'S' then 'system'         when 'U' then 'individual user'     end as schema_definer_type from syscat.schemata     where schemaname not like 'SYS%' and  schemaname not IN ('SQLJ', 'NULLID') order by schema_name   

DB2: To list indexes on a table

  SELECT INDNAME AS INDEX_NAME,        UNIQUERULE AS INDEX_TYPE,        COLNAMES AS COLUMNS FROM SYSCAT.INDEXES WHERE TABNAME = 'XTMW_CONSTRUCTOR'   AND TABSCHEMA = 'WCS';   

DB2: Grant access on table

 GRANT SELECT ON TABLE HR.EMPLOYEES TO USER JOHN_DOE; GRANT SELECT ON TABLE HR.EMPLOYEES TO ROLE role_name ;

Unix: to find a string within a file

> grep -RHlz  "robocopy" /usr/opt/app/  the string "robocopy" in it somewhere in a subtree of /usr/opt/app and you need to find it.

DB2: To find when a table was ALTERed

 SELECT      TABSCHEMA AS SCHEMA_NAME,      TABNAME AS TABLE_NAME,      ALTER_TIME AS LAST_MODIFIED_TIME FROM      SYSCAT.TABLES WHERE      TYPE = 'T'      AND TABSCHEMA NOT LIKE 'SYS%' -- Exclude system schemas ORDER BY      ALTER_TIME DESC;

DB2: change ownership of a table

 db2 "transfer ownership of table wcs.X_PRODUCT_MASTER_FEED to user wcs" Run the following to check the ownership: select * from syscat.tables where tabname = 'X_PRODUCT_PRICING_INVENTORY' with ur; The entry in the  OWNER column must match the entry in the TABSCHEMA column.