postgresql-psql

Execute PostgreSQL psql commands for database administration and query automation.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/nodays-off/Hogans-Alley --skill postgresql-psql-nodays-off
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql-psql
Source: https://github.com/nodays-off/Hogans-Alley/tree/main/skills/databases/postgresql-psql
Command: npx skills add https://github.com/nodays-off/Hogans-Alley --skill postgresql-psql-nodays-off

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill empowers users to master PostgreSQL's psql command-line client, simplifying complex database interactions. It provides a comprehensive guide for everything from basic query execution to advanced administration, scripting, and performance tuning, making database management efficient and intuitive.

Core Features & Use Cases

  • Interactive Database Management: Connect to databases, execute SQL queries, and manage objects (tables, views, functions) using psql's extensive meta-commands.
  • Advanced Scripting & Automation: Write powerful SQL scripts, integrate with Bash, and automate routine tasks like backups, health checks, and scheduled maintenance.
  • Performance Analysis & Debugging: Utilize EXPLAIN for query plan analysis, monitor active and blocking queries, and optimize database performance directly from the terminal.
  • Use Case: Automate your daily database health checks, create complex data migration scripts, or perform deep performance analysis without leaving your terminal.

Quick Start

Connect to your PostgreSQL database and list all tables in the public schema. psql -U postgres -d your_database -c "\dt"

Frequently Asked Questions about postgresql-psql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect to a PostgreSQL database from the command line?

Use psql with connection parameters: `psql -U username -d database_name -h hostname`. psql is PostgreSQL's command-line client that establishes interactive or scripted database sessions. Specify user, database name, and host; omit host for local connections via Unix socket.

How do I automate PostgreSQL tasks like backups and health checks?

Write SQL scripts and integrate them with Bash for automation. psql executes scripts with the `-f` flag and meta-commands, enabling scheduled backups, routine maintenance, and health monitoring without manual intervention across development and operations workflows.

How can I analyze and optimize slow PostgreSQL queries?

Use `EXPLAIN` in psql to view query execution plans, then identify bottlenecks in table scans, joins, and sorts. psql also supports monitoring active queries and blocking sessions directly from the terminal to troubleshoot performance issues and optimize database operations.

Can I use psql to manage database objects like tables, views, and functions?

Yes, psql's meta-commands handle object management: `\dt` lists tables, `\dv` lists views, `\df` lists functions. These commands simplify interactive database administration without writing SQL DDL statements, making schema exploration and object inspection efficient.

What connection options does psql support for remote and secure databases?

psql supports local sockets, remote TCP connections, SSL encryption, and SSH tunneling. Credential handling via connection strings, environment variables, and `.pgpass` files secures authentication across development, remote, and production database environments.

How do I import and export data using psql?

psql supports `COPY` for bulk data transfer and `\copy` for client-side import/export to CSV and text formats. These commands enable data migration, seeding, and backup workflows integrated with SQL scripting for streamlined data management tasks.