Posts

How to find users in PostgreSQL

In PostgreSQL, there is a system table called  pg_user . You can run a query and get the information about these Users. SELECT * FROM pg_user; The  pg_user  table contains the following columns: Column Explanation usename User name (ie: postgres, techonthenet, etc) usesysid User ID (number assigned by PostgreSQL) usecreatedb Boolean value indicating whether user can create databases (t or f) usesuper Boolean value indicating whether user is a superuser (t or f) usecatupd Boolean value indicating whether user can update system catalogs (t or f) userepl Boolean value indicating whether user can initiate replication (t or f) passwd Password for user displayed as ******** valuntil Time when password will expire useconfig Session defaults for run-time configuration variables

How to use ALTER USER command in PostgreSQL

ALTER USER changes the attributes of a PostgreSQL user account.  Examples 1.Change a user's password:   ALTER USER davide WITH PASSWORD 'hu8jmn3'; 2.Change the expiration date of the user's password:   ALTER USER manuel VALID UNTIL 'Jan 31 2030'; 3.Change a password expiration date, specifying that the password        should expire at midday on 4th May 2005 using the time zone which is    one hour ahead of UTC:    ALTER USER chris VALID UNTIL 'May 4 12:00:00 2005 +1'; 4.Make a password valid forever:   ALTER USER fred VALID UNTIL 'infinity'; 5.Give a user the ability to create other users and new databases:   ALTER USER miriam CREATEUSER CREATEDB;

How to CREATE USER in PostgreSQL

CREATE USER  adds a new user to a  PostgreSQL  database cluster. You must be a database superuser to use this command. Examples 1. Create a user with no password:    CREATE USER jonathan; 2. Create a user with a password:    CREATE USER davide WITH PASSWORD 'jw8s0F4'; 3. Create a user with a password that is valid until the end of        2004. After one second has ticked in 2005, the password is no        longer valid.   CREATE USER xen WITH PASSWORD 'jw8s0F4' VALID UNTIL '2005-01-01'; 4. Create an account where the user can create databases:    CREATE USER manuel WITH PASSWORD 'jw8s0F4' CREATEDB; Compatibility The CREATE USER statement is a PostgreSQL extension. The SQL standard leaves the definition of users to the implementation.

Start the Managed recovery process (MRP) on standby server - ORACLE DATAGUARD

  What is MRP in Oracle database? Managed recovery process (MRP) The managed recovery process (MRP) applies information from the archived redo logs to the standby database.  When performing managed recovery operations, log apply services automatically apply archived redo logs to maintain transactional synchronization with the primary database. Start the apply process on standby server. # Foreground redo apply. Session never returns until cancel.  ALTER DATABASE RECOVER MANAGED STANDBY DATABASE; # Background redo apply. Control is returned to the session once the apply process is started. ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION; If you need to cancel the apply process, issue the following command. ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; If you prefer, you can set a delay between the arrival of the archived redo log and it being applied on the standby server using the following commands. ALTER DATABASE RECOVER MANAGED STANDBY ...

How To Unlock a User in Oracle

To unlock a user in Oracle, you need to follow these steps:    1. log in to the Oracle Database as a SYS user.    2. use ALTER USER statement to unlock the user:        ALTER USER <username> IDENTIFIED BY <password> ACCOUNT UNLOCK; NOTE: if you unlock an account without resetting the password, then the password remains expired, therefore, the IDENTIFIED BY password clause is necessary.  The first time the user logs in to the Oracle Database, he needs to change his password.

PostgreSQL CREATE TABLESPACE

A tablespace is a location on the storage device where PostgreSQL database stores data file containing database objects such as indexes, and tables. PostgreSQL uses a tablespace to map a logical name to a physical location on disk. PostgreSQL comes with two default tablespaces:  - pg_default tablespace --->  stores user data.  - pg_global tablespace   --->  stores global data.   Advantages of using tablespaces: 1. if a partition on which the cluster was initialized is out of         space, you can create a new tablespace on a different partition       and   use it until you reconfigure the system. 2. you can use statistics to optimize database performance. For         example, you can place the frequent access indexes or tables on       devices that perform very fast e.g., solid-state devices, and put     the tables containing archiv...

How to resolve - ERROR: cannot cast type numeric to boolean

There is no direct cast defined between numeric and boolean. You can use integer as middle-ground.  ALTER TABLE <schema>.<table_name> ALTER <column_name> TYPE bool USING (<column_name>::int::bool); Ex: ALTER TABLE SANGA.SANGA_H_TRANSACTION_DETAILS  ALTER is_active TYPE bool USING (is_active::int::bool);