POSTGRES DB SCRIPTS
Please write in comment section, if links are not working.
DATABASE MANAGEMENT
Create a database in postgres
How to connect to postgres db
Drop database in postgres
Find the database details in postgres
Find postgres db sizes
How to find timezone info
How to find postgres version
How to enable archiving(wal) in postgres
How to rotate server log in postgres
Find query execution time using pg_stat_statement
How to find data directory location
Find current sessions in postgres
Kill a session in postgres
Cancel a session in postgres
Kill all session of a user in postgres
Find locks present in postgres
Find blocking sessions in postgres
Find location of postgres conf files
Find current data/time on postgres db
Find extension details
Find startup time and uptime postgres
Find archiver process status
Find postgres configuration values
Find the last pg config reload time
How to do wal switch manually
Monitor archiving progress
View/modify connection limit of database
Find wal file details and its size
Find temp file usage of databases
OBJECT MANAGEMENT
Create/drop table in postgres
Create/drop index commands in postgres
Find list of schemas in postgres
list of objects presents in a schema
Find schema wise size in postgres db
Find top 10 big tables in postgres
Find tables and its index sizes
List down index details in postgres
Find the size of a column
Find respective physical file of a table/index
Find list of views present
Manage sequences in postgres
Create Partial index in postgres
Find foreign key details in postgres
Find specific table/index size
Find list of partitioned table details
MAINTENANCE
Update statistics of a table using analyze
Reorg a table using VACUUM command
Reorg a table using VACUUM FULL command
Manage autovacuum process in postgres
Rebuild indexes using REINDEX
Monitor index creation or rebuild
Monitor vacuum operation
find and change statistics level of a column
Find vaccum settings of tables
Modify autovacuum setting of table/index
Find last vaccum/analyze details of a table
Find how much bloating a table has
USER MANAGEMENT
List users present in postgres
List roles present in postgres
create/drop user in postgres
Create/drop role in postgres
Alter an user in postgres
Convert a user to superuser
Set password to original one without knowing
GRANT privilege commands
REVOKE privilege commands
Create user profile - EDB Postgres
Create/Drop schema in postgres
Find search_path setting of users
Set search_path of a user in postgres
Find privileges granted to a user postgres
Find the roles granted to user/role
Find how much bloating a table has
TABLESPACE MANAGEMENT
View tablespace info in postgres
create/drop/rename tablespace in postgres
find/change default tablespace
find/change default temp tablespace
How to change tablespace owner
Move table/index to different tablespace
Move database to new tablespace in postgres
BACKUP & RECOVERY
export table data to file using COPY
AUDITING & SECURITY
Find pg_hba.conf file content
Enable auditing for ddl/dml statement
Enable audit for log on/log off to postgres
NETWORK
Find foreign server details
Find list of foreign tables
List foreign data wrapper
Find user mapping for FDW
Create database link between postgres dbs
Create/Modify foreign server
REPLICATION
Check streaming recovery status
Check replication details on primary server
Get received /replayed WAL records on standby(replication)
How to stop /resume recovery in standy(replication)
Find lag in streaming replication
Manage replication slots
Find subscription details in logic replication
PERFORMANCE
Find foreign server details
-
- This page will be updated regularly with new scripts.Please provide suggestions to improve this page.
Keep visiting us.
Thank you very much ,
Scripts stopped opening
Dear, This has been fixed. Please let me know if you are still facing issue?
Regards
Admin
Unchanged. Mozilla Firefox without blocking scripts and clean Microsoft Edge – when you click on the link, nothing happens. P.S. JavaScript on a page like this is very bad.
Yes issue is due to jquery It is breaking the js scripts. Thank. you for pointing out.We are working on it.
Admin
It should work now dear.
error with postgresql scripts, they don’t open when you click on them
please help with postgresql scripts then cannot open
postgres scripts don’t work
Hello,
The links are not working for me, correct?
If possible, how to put it on an onedrive / googledrive and pass it on to us?
Apologies to everyone, I will fix this issue within 2 to 3 hours.
Dear All,
All the links are working fine now. Please provides your suggestions to improve this page.
good site I like it. Post few replication scripts. thanks
Hi,
I just need to compress the WAL and archive files
could you please update it..
Hi ,I use your site very often ,great job
please post replication steps
I will try brother.
Thanks for your work. It’s very helpful.
Hello Team,
Thanks for sharing very good scripts ..
But one thing ..
Is there anyway to get all DB objects like triggers, types, sequences etc.. in single command ? If yes please provide here .
I see list of objects presents in a schema in this Web page …But not for list of objects presents in a Databases .
Please add this script too.
Will add that for sure.
Can I get script to list all objects details for particular schema, Seems the one updated is not working
How to get Privilege/role granted to user in postgres.
— List down table level privileges of user
SELECT table_catalog, table_schema, table_name, privilege_type
FROM information_schema.table_privileges
WHERE grantee = ‘USER_NAME’;
— List down usage privileges of a user:
select * from usage_privileges where grantee=’USER_NAME’;
Thanks, Its showing only your current db. suppose in my cluster I have more than 100+ db
Please give me me query how to get at global level.
Hi,
Could you please upload script to get privilege’s assigned to role.
Hi
Thanks for this notes. I am beginner to Postgres could you please share me installation and configuration of Postgres on Linux pls .
Very good information ..Thanks for compiling all things
Thank you for sharing so many great scripts. but could you also please provide a script that can read errors from the log file and then send the error messages to an email address for notifications?
Thanks so much!
Nice collection, would be nice if can be downloaded as a zip file though 🙂