Search
 
SCRIPT & CODE EXAMPLE
 

SQL

postgresql list users

postgres=# du
Comment

how to know the username of postgresql

SELECT current_user,
       user,
       session_user,
       current_database(),
       current_catalog,
       version();
Comment

postgres list users and roles

SELECT r.rolname, r.rolsuper, r.rolinherit,
  r.rolcreaterole, r.rolcreatedb, r.rolcanlogin,
  r.rolconnlimit, r.rolvaliduntil,
  ARRAY(SELECT b.rolname
        FROM pg_catalog.pg_auth_members m
        JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)
        WHERE m.member = r.oid) as memberof
, r.rolreplication
, r.rolbypassrls
FROM pg_catalog.pg_roles r
WHERE r.rolname !~ '^pg_'
ORDER BY 1;
Comment

postgres list users

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     AS role_attributes
FROM pg_catalog.pg_user
ORDER BY role_name DESC;
Comment

PREVIOUS NEXT
Code Example
Sql :: how to drop a unique constraint in sql 
Sql :: sp in sql server 
Sql :: How to check if the column exists in sql table 
Sql :: how to insert multiple rows in sql 
Sql :: IS NOT NULL statement 
Sql :: postgres select duplicate columns 
Sql :: sql count null values in all columns 
Sql :: sql select first and last record of each group 
Sql :: sqlite get last 
Sql :: output table plsql 
Sql :: 3rd highest value in sql 
Sql :: csv into data postgres 
Sql :: install postgresql 10 centos 7 
Sql :: postgresql remove new line from string 
Sql :: activate log mariadb 
Sql :: mysql get nth highest 
Sql :: where with multiple conditions in mongodb 
Sql :: mysql run sql file 
Sql :: sql order by multiple columns 
Sql :: opening xampp mysql in cmd ubuntu 
Sql :: restart serial number for postgres 
Sql :: mysql auerries to find the name starting with vowel letter 
Sql :: how to find average in sql 
Sql :: how to view created temporary tables in mysql 
Sql :: how to select random rows from a table 
Sql :: install latest mysql 8 linux server 
Sql :: PL SQL VARRAY of records 
Sql :: create table with timestamp postgresql 
Sql :: command to give readonly access to a postgres sql user 
Sql :: oracle previous year 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =