PostgreSQL Syntax Reference

Map PostgreSQL grammar rules to DDL generation and SQL parsing.

994|57|Updated Jun 8, 2025
One-click install
npx skills add https://github.com/pgschema/pgschema --skill postgresql-syntax-reference
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: PostgreSQL Syntax Reference
Source: https://github.com/pgschema/pgschema/tree/main/.claude/skills/postgres_syntax
Command: npx skills add https://github.com/pgschema/pgschema --skill postgresql-syntax-reference

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostgreSQL's parser and grammar are complex, and understanding gram.y and related parser code helps implement and validate DDL generation and SQL parsing in pgschema.

Core Features & Use Cases

  • Provides a structured map of grammar rules (gram.y, parse utilities) to guide DDL generation and SQL interpretation.
  • Serves as a reference for debugging, extending support across PostgreSQL versions 14-18, and aligning internal diff logic with actual parser behavior.
  • Use cases include understanding CREATE/ALTER/DROP statement syntax, exploring tokenization, and validating SQL structures when implementing pgschema features.

Quick Start

Consult the grammar reference before implementing or reviewing SQL parsing logic to confirm syntax and token rules for your target DDL statements.

Frequently Asked Questions about PostgreSQL Syntax Reference

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

FAQPage Schema
How do I understand PostgreSQL grammar rules for writing correct DDL?

PostgreSQL grammar rules for DDL are clarified by mapping parser grammar and tokenization to guide correct SQL interpretation and DDL generation. You can consult this structured reference to confirm syntax and token rules for target statements.

How does the PostgreSQL parser handle CREATE and ALTER statements?

The PostgreSQL parser processes CREATE and ALTER statements using defined grammar rules that map to DDL generation and validation. This reference clarifies how these SQL constructs are tokenized and interpreted for accurate parsing logic.

Can I use this reference to debug SQL parsing logic across PostgreSQL versions 14-18?

Yes, you can use this reference to debug SQL parsing logic across PostgreSQL versions 14-18. It aligns internal diff logic with actual parser behavior and helps cross-reference gram.y with code paths for version-specific support.

What is the best way to map gram.y grammar rules to DDL generation?

The best way to map gram.y grammar rules to DDL generation is to use a structured reference that connects parser grammar to DDL generation, validation, and code generation for internal diff and parsing components.

Why does my SQL parsing logic fail to validate complex DDL structures?

SQL parsing logic fails to validate complex DDL structures when internal diff logic is not aligned with actual PostgreSQL parser behavior. Referencing grammar rules and parse utilities helps confirm syntax and token rules for accurate validation.