Token导航 LogoToken导航TokenDH.com
前端设计需要联网unknown未标认证来源可访问许可证需确认审计未展示

postgresqlPostgreSQL 数据库

Agent Skill

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

总安装

339

周安装

14

下载量

111
Local Agent

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:postgresql(PostgreSQL 数据库)
来源仓库:https://smithery.ai
仓库路径:postgresql
安装命令:
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。当前暂无明确安装命令,请以来源页面说明为准。

简介

用于辅助数据库表结构和查询语句处理。

  • 适合分析 schema、编写 SQL 或排查查询问题。
  • 使用时需明确数据库类型和连接环境。postgresql 属于前端设计类 Skill,可作为该场景下的辅助能力补充。
  • 涉及删除、更新或迁移时应优先 dry-run 或备份。
  • 区分只读分析与写入变更,避免误操作。

SKILL.md

PostgreSQL Skill

Comprehensive PostgreSQL 18 documentation covering SQL syntax, database administration, PL/pgSQL programming, and development best practices. Generated from official PostgreSQL documentation.

When to Use This Skill

This skill should be activated when:

Database Design & Schema

  • Creating tables, views, indexes, and constraints
  • Designing foreign key relationships
  • Implementing table inheritance
  • Planning database architecture

SQL Queries

  • Writing SELECT, INSERT, UPDATE, DELETE statements
  • Performing JOIN operations (INNER, LEFT OUTER, RIGHT OUTER, FULL)
  • Using aggregate functions and GROUP BY
  • Building complex queries with subqueries and CTEs

Transactions & Data Integrity

  • Managing transactions with BEGIN, COMMIT, ROLLBACK
  • Implementing savepoints for partial rollbacks
  • Understanding ACID properties
  • Handling concurrent access

PL/pgSQL Programming

  • Creating stored functions and procedures
  • Writing triggers
  • Implementing complex business logic in the database
  • Performance optimization through server-side computation

Administration

  • Installing and configuring PostgreSQL
  • Running regression tests
  • Managing users, roles, and permissions
  • Backup and recovery operations
  • Understanding Write-Ahead Logging (WAL)

Key Concepts

ACID Properties

PostgreSQL is fully ACID-compliant:

  • Atomicity: Transactions are all-or-nothing operations
  • Consistency: Database moves from one valid state to another
  • Isolation: Concurrent transactions don't see each other's incomplete changes
  • Durability: Committed transactions survive system failures via WAL

Write-Ahead Logging (WAL)

Changes are logged before being applied to data files. This enables:

  • Crash recovery without data loss
  • Point-in-time recovery
  • Online backup and replication
  • Reduced disk I/O (sequential log writes vs. random data page writes)

PL/pgSQL Advantages

Server-side procedural language that:

  • Eliminates client/server round trips
  • Avoids transferring intermediate results
  • Reduces query parsing overhead
  • Can use all SQL data types and functions

Quick Reference

Creating Tables

Basic table creation (from official docs):

CREATE TABLE my_first_table (
    first_column text,
    second_column integer
);

Table with foreign key constraint (from official docs):

CREATE TABLE cities (
    name     varchar(80) PRIMARY KEY,
    location point
);

CREATE TABLE weather (
    city      varchar(80) REFERENCES cities(name),
    temp_lo   int,
    temp_hi   int,
    prcp      real,
    date      date
);

Table inheritance (from official docs):

CREATE TABLE cities (
    name       text,
    population real,
    elevation  int     -- (in ft)
);

CREATE TABLE capitals (
    state      char(2) UNIQUE NOT NULL
) INHERITS (cities);

Querying Data

Basic SELECT (from official docs):

SELECT * FROM weather;

SELECT city, temp_lo, temp_hi, prcp, date FROM weather;

Computed columns with aliases (from official docs):

SELECT city, (temp_hi+temp_lo)/2 AS temp_avg, date FROM weather;

JOIN operations (from official docs):

-- Inner join
SELECT * FROM weather JOIN cities ON city = name;

-- Explicit column selection with qualified names
SELECT weather.city, weather.temp_lo, weather.temp_hi,
       weather.prcp, weather.date, cities.location
    FROM weather JOIN cities ON weather.city = cities.name;

Creating Views

Encapsulate complex queries (from official docs):

CREATE VIEW myview AS
    SELECT name, temp_lo, temp_hi, prcp, date, location
        FROM weather, cities
        WHERE city = name;

SELECT * FROM myview;

Creating Indexes

Basic index creation (from official docs):

CREATE TABLE test1 (
    id integer,
    content varchar
);

CREATE INDEX test1_id_index ON test1 (id);

Modifying Data

UPDATE statement (from official docs):

UPDATE weather
    SET temp_hi = temp_hi - 2,  temp_lo = temp_lo - 2
    WHERE date > '1994-11-28';

INSERT statement (from official docs):

INSERT INTO weather VALUES ('Berkeley', 45, 53, 0.0, '1994-11-28');

Transactions

Basic transaction block (from official docs):

BEGIN;
UPDATE accounts SET balance = balance - 100.00
    WHERE name = 'Alice';
-- ... more operations ...
COMMIT;

Using savepoints (from official docs):

BEGIN;
UPDATE accounts SET balance = balance - 100.00
    WHERE name = 'Alice';
SAVEPOINT my_savepoint;
UPDATE accounts SET balance = balance + 100.00
    WHERE name = 'Bob';
-- oops ... forget that and use Wally's account
ROLLBACK TO my_savepoint;
UPDATE accounts SET balance = balance + 100.00
    WHERE name = 'Wally';
COMMIT;

Embedded SQL (ECPG)

Prepared statements in C (from official docs):

EXEC SQL BEGIN DECLARE SECTION;
const char *stmt = "INSERT INTO test1 VALUES(?, ?);";
EXEC SQL END DECLARE SECTION;

EXEC SQL PREPARE mystmt FROM :stmt;
EXEC SQL EXECUTE mystmt USING 42, 'foobar';

Database Administration

Creating a database (from official docs):

$ createdb mydb

Removing a database (from official docs):

$ dropdb mydb

Setting up shared libraries (from official docs):

LD_LIBRARY_PATH=/usr/local/pgsql/lib
export LD_LIBRARY_PATH

Running Tests

Parallel regression tests (from official docs):

make check        # Against temporary installation
make installcheck # Against running server
make check-world  # All test suites

Reference Files

This skill includes comprehensive documentation in references/:

getting_started.md

Source: Official PostgreSQL 18 Documentation Confidence: Medium Pages: 46 Content:

  • Installation requirements and procedures
  • Creating databases and connecting
  • SQL tutorial (tables, queries, joins)
  • Transactions and savepoints
  • Views, foreign keys, inheritance
  • Running regression tests

sql.md

Source: Official PostgreSQL 18 Documentation Confidence: Medium Pages: 1088 Content:

  • Complete SQL command reference
  • PL/pgSQL procedural language
  • User-defined functions and procedures
  • Security labels and permissions
  • Dynamic SQL with ECPG
  • Information schema details

index.md

Source: Official PostgreSQL 18 Documentation Confidence: Medium Content:

  • Documentation category index
  • Navigation guide to reference files

Working with This Skill

For Beginners

  1. Start with references/getting_started.md for installation and basic SQL
  2. Follow the tutorial sections (Chapter 2: SQL Language, Chapter 3: Advanced Features)
  3. Practice with the weather/cities example tables from the docs
  4. Learn transaction basics with BEGIN/COMMIT/ROLLBACK

For Intermediate Users

  1. Explore references/sql.md for complete SQL command syntax
  2. Study PL/pgSQL for server-side programming (Section 41)
  3. Learn about indexes and query optimization (Chapter 11)
  4. Understand views and foreign keys for better schema design

For Advanced Users

  1. Deep dive into PL/pgSQL for complex stored procedures
  2. Study Write-Ahead Logging for understanding durability
  3. Explore embedded SQL (ECPG) for C applications
  4. Reference the information schema for metadata queries

Navigation Tips

  • Use section numbers (e.g., "31.1", "41.1") to locate specific topics
  • The URL patterns follow PostgreSQL docs structure (e.g., /docs/18/tutorial-select.html)
  • Code examples are language-tagged for proper syntax highlighting
  • Look for "Examples:" sections for practical code samples

Common Patterns

Pattern: Referential Integrity with Foreign Keys

Ensure data consistency by declaring foreign key constraints:

CREATE TABLE orders (
    order_id    serial PRIMARY KEY,
    customer_id integer REFERENCES customers(id),
    order_date  date
);

Pattern: Safe Updates with Transactions

Wrap related changes in a transaction block:

BEGIN;
-- Multiple related operations
UPDATE inventory SET quantity = quantity - 1 WHERE product_id = 123;
INSERT INTO order_items (order_id, product_id) VALUES (456, 123);
COMMIT;

Pattern: Query Encapsulation with Views

Hide complexity behind a view interface:

CREATE VIEW active_customers AS
    SELECT c.*, COUNT(o.order_id) as order_count
    FROM customers c
    LEFT JOIN orders o ON c.id = o.customer_id
    WHERE c.status = 'active'
    GROUP BY c.id;

Pattern: Performance with Indexes

Create indexes on frequently queried columns:

CREATE INDEX idx_orders_customer ON orders(customer_id);
CREATE INDEX idx_orders_date ON orders(order_date);

Error Handling

Foreign Key Violation

ERROR:  insert or update on table "weather" violates foreign key constraint
DETAIL:  Key (city)=(Berkeley) is not present in table "cities".

Solution: Insert the referenced row first, or use ON DELETE/UPDATE actions.

Transaction Aborted

After an error in a transaction, you must either:

  • ROLLBACK to abort and start fresh
  • ROLLBACK TO savepoint to return to a known good state

Resources

references/

Organized documentation extracted from official PostgreSQL sources:

  • Detailed explanations with context
  • Code examples with language annotations
  • Links to original documentation URLs
  • Hierarchical table of contents

scripts/

Add helper scripts for common automation tasks:

  • Database migration scripts
  • Backup and restore procedures
  • Performance testing utilities

assets/

Add templates and examples:

  • Schema templates
  • Sample data files
  • Configuration examples

Notes

  • This skill was generated from PostgreSQL 18 official documentation
  • Reference files preserve original structure and examples
  • Code examples include language tags for syntax highlighting
  • Examples prioritize practical, real-world patterns from official docs
  • PL/pgSQL is installed by default since PostgreSQL 9.0

Updating

To refresh this skill with updated documentation:

  1. Re-run the scraper with the PostgreSQL configuration
  2. The skill will be rebuilt with the latest information
  3. Check for new features in major version releases

Source Information

Primary Source: PostgreSQL 18 Official Documentation Documentation URL: https://www.postgresql.org/docs/18/ Source Confidence: Medium (official documentation) Last Updated: Generated from current documentation

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Local Agent

79.68%
按下载量换算88

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills