Posts

Showing posts from May, 2023

Postgres: To connect to a schema

 cfdvlp=> show search_path;    search_path -----------------  "$user", public (1 row) cfdvlp=> set search_Path to ordadmin; SET Or if you want multiple schemas: SET search_path TO myschema, public;

Postgres: To generate the SELECT statements to GRANT

  SELECT 'GRANT SELECT ON '||schemaname||'."'||tablename||'" TO chartio_read_only_user;' FROM pg_tables WHERE schemaname IN ('public') ORDER BY schemaname, tablename;

Postgres: To create a new user (also called role)

  CREATE ROLE  read_only_user LOGIN PASSWORD 'secure_password'; Grant the necessary privileges for the new user to connect to your database: GRANT CONNECT ON DATABASE exampledb TO read_only_user; GRANT USAGE ON SCHEMA public TO read_only_user; alter role eisuser with login; CREATE ROLE pan187 LOGIN PASSWORD 'tempPwd_1'; GRANT CONNECT ON DATABASE cfperf TO pts304; GRANT usage ON SCHEMA cfadmin TO pts304; GRANT USAGE ON SCHEMA cfaudit TO pts304; GRANT USAGE ON SCHEMA cmsadmin TO pts304; GRANT USAGE ON SCHEMA cmtadmin TO pts304; GRANT USAGE ON SCHEMA ctlgadmin TO pts304; GRANT USAGE ON SCHEMA ctlgadmin2 TO pts304; GRANT USAGE ON SCHEMA grpadmin TO pts304; GRANT USAGE ON SCHEMA invadmin TO pts304; GRANT USAGE ON SCHEMA ordadmin TO pts304; GRANT USAGE ON SCHEMA seadmin TO pts304; GRANT select,insert,update,delete ON all tables in schema cfadmin TO pts304; GRANT select,insert,update,delete ON all tables in SCHEMA cfaudit TO pts304; GRANT select,insert,update,delete ON...

Postgres: connect to a database using psql

\c databasename;   cfdvlp=> \c cftest; psql (15.2, server 14.5) SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off) You are now connected to database "cftest" as user "postgres". cftest=>

Postgres: Alter existing user permissions

  =# ALTER USER role_specification WITH OPTION1 OPTION2 OPTION3 ; =# ALTER USER librarian WITH SUPERUSER ; ALTER ROLE These options range from  CREATEDB ,  CREATEROLE ,  CREATEUSER , and even  SUPERUSER . Additionally, most options also have a negative counterpart, informing the system that you wish to  deny  the user that particular permission. These option names are the same as their assignment counterpart, but are prefixed with  NO  (e.g.  NOCREATEDB ,  NOCREATEROLE ,  NOSUPERUSER ). =# ALTER USER librarian WITH NOSUPERUSER ; ALTER ROLE

Posgres: view existing user permissions

 => \du cfdvlp=> \du                                                       List of roles          Role name         |                         Attributes                         |           Member of ---------------------------+------------------------------------------------------------+--------------------- -----------  cf_admin                  | Cannot login                                               | {}  cloudsqladmin           ...

Posgres: To list all existing users

  SELECT usename FROM pg_user ; cfdvlp=> SELECT usename FROM pg_user;        usename ----------------------  cloudsqladmin  cloudsqlsuperuser  cloudsqlagent  cloudsqlimportexport  cloudsqlreplica  pgcfadmin  postgres  ordadmin (8 rows)

Oracle: To cleanup .patch_storage

$ORACLE_HOME/OPatch/opatch util cleanup

WIN: to tell when a server was rebooted

Uptime  In the CMD window: Microsoft Windows [Version 10.0.17763.4252] (c) 2018 Microsoft Corporation. All rights reserved. H:\>systeminfo | find /i "Boot Time" System Boot Time:          4/30/2023, 1:30:01 AM H:\>