Professional Documents
Culture Documents
su - user(i.e. postgres)
psql
Disconnect:
\q
Find Version
SELECT version();
Server Uptime
SELECT date_trunc('second', current_timestamp - pg_postmaster_start_time()) as
uptime;dd
Biggest Tables
SELECT table_name ,pg_relation_size(table_schema || '.' || table_name) as size
FROM information_schema.tables
WHERE table_schema
NOT IN ('information_schema', 'pg_catalog')
ORDER BY size DESC
LIMIT 10;
Rows in a table
SELECT count(*) FROM table;
CREATE USER:
useradd _______
PASSWORD - passwd
DELETING USERS:
userdel _____
select table_schema,
table_name,
(xpath('/row/cnt/text()', xml_count))[1]::text::int as row_count
from (
select table_name, table_schema,
query_to_xml(format('select count(*) as cnt from %I.%I', table_schema,
table_name), false, true, '') as xml_count
from information_schema.tables
where table_schema = 'public' --<< change here for the schema you want
AND table_name != 'awsdms_ddl_audit'
) t
ORDER BY TABLE_NAME
-----------------------------------------------------------------------------------
---------------------
-----------------------------------------------------------------------------------
--------------------
-----------------------------------------------------------------------------------
--------------------
#Then try
pg_terminate_ backend(pid).
Specific User:
ALTER USER foo CONNECTION LIMIT 0;