PostgreSQL 正體中文使用手冊
PostgreSQL.TW官方使用手冊小島故事加入社團
11
11
  • 簡介
  • 前言
    • 1. 什麼是PostgreSQL?
    • 2. PostgreSQL沿革
    • 3. 慣例
    • 4. 其他參考資訊
    • 5. 問題回報指南
  • I. 新手教學
    • 1. 入門指南
      • 1.1. 安裝
      • 1.2. 基礎架構
      • 1.3. 建立一個資料庫
      • 1.4. 存取一個資料庫
    • 2. SQL查詢語言
      • 2.1. 簡介
      • 2.2. 概念
      • 2.3. 創建一個新的資料表
      • 2.4. 資料列是資料表的組成單位
      • 2.5. 資料表的查詢
      • 2.6. 交叉查詢
      • 2.7. 彙總查詢
      • 2.8. 更新資料
      • 2.9. 刪除資料
    • 3. 先進功能
      • 3.1. 簡介
      • 3.2. 檢視表(View)
      • 3.3. 外部索引鍵
      • 3.4. 交易安全
      • 3.5. 窗函數
      • 3.6. 繼承
      • 3.7. 結論
  • II. SQL查詢語言
    • 4. SQL語法
      • 4.1. 語法結構
      • 4.2. 參數表示式
      • 4.3. 函數呼叫
    • 5. 定義資料結構
      • 5.1. 認識資料表
      • 5.2. 預設值
      • 5.3. 限制條件
      • 5.4. 系統欄位
      • 5.5. 表格變更
      • 5.6. 權限
      • 5.7. 資料列安全原則
      • 5.8. Schemas
      • 5.9. 繼承
      • 5.10. 分割資料表
      • 5.11. 外部資料
      • 5.12. 其他資料庫物件
      • 5.13. 相依性追蹤
    • 6. 資料處理
      • 6.1. 新增資料
      • 6.2. 更新資料
      • 6.3. 刪除資料
      • 6.4. 修改並回傳資料
    • 7. 資料查詢
      • 7.1. 概觀
      • 7.2. 資料表表示式
      • 7.3. 取得資料列表
      • 7.4. 合併查詢結果
      • 7.5. 資料排序
      • 7.6. 指定資料範圍
      • 7.7. 列舉資料
      • 7.8. 遞迴查詢(Common Table Expressions)
    • 8. 資料型別
      • 8.1. 數字型別
      • 8.2. 貨幣型別
      • 8.3. 字串型別
      • 8.4. 位元組型別(bytea)
      • 8.5. 日期時間型別
      • 8.6. 布林型別
      • 8.7. 列舉型別
      • 8.8. 地理資訊型別
      • 8.9. 網路資訊型別
      • 8.10. 位元字串型別
      • 8.11. 全文檢索型別
      • 8.12. UUID型別
      • 8.13. XML型別
      • 8.14. JSON型別
      • 8.15. 陣列
      • 8.16. 複合型別
      • 8.17. 範圍型別
      • 8.18. 指標型別
      • 8.19. pg_lsn型別
      • 8.20. 概念型別
    • 9. 函式及運算子
      • 9.1. 邏輯運算子
      • 9.2. 比較函式及運算子
      • 9.3. 數學函式及運算子
      • 9.4. 字串函式及運算子
      • 9.5. 位元字串函式及運算子
      • 9.6. 二元字串函式及運算子
      • 9.7. 特徵比對
      • 9.8. 型別轉換函式
      • 9.9 日期時間函式及運算子
      • 9.10. 列舉型別函式
      • 9.11. 地理資訊函式及運算子
      • 9.12. 網路位址函式及運算子
      • 9.13. 文字檢索函式及運算子
      • 9.14. XML函式
      • 9.15. JSON函式及運算子
      • 9.16. 序列函式
      • 9.17. 條件表示式
      • 9.18. 陣列函式及運算子
      • 9.19. 範圍函式及運算子
      • 9.20. 彙總函數
      • 9.21. Window函式
      • 9.22. 子查詢
      • 9.23. 資料列與陣列的比較運算
      • 9.24. 集合回傳函式
      • 9.25. 系統資訊函數
      • 9.26. 系統管理函式
      • 9.27. 觸發函式
      • 9.28. 事件觸發函式
    • 10. 型別轉換
      • 10.1. 概觀
      • 10.2. 運算子
      • 10.3. 函式
      • 10.4. 資料儲存轉換規則
      • 10.5. UNION、CASE 等相關結構
      • 10.6. SELECT輸出規則
    • 11. 索引(Index)
      • 11.1. 簡介
      • 11.2. 索引型別
      • 11.3. 多欄位索引
      • 11.4. 索引與ORDER BY
      • 11.5. 善用多個索引
      • 11.6. 唯一值索引
      • 11.7. 表示式索引
      • 11.8. 部份索引(partial index)
      • 11.9. 運算子物件及家族
      • 11.10. 索引與排序規則
      • 11.11. 索引限定查詢(Index-only scan)
      • 11.12. 檢查索引運用
    • 12. 全文檢索
      • 12.1. 簡介
      • 12.2. 查詢與索引
      • 12.3. 細部控制
      • 12.4. 延伸功能
      • 12.5. 斷詞
      • 12.6. 字典
      • 12.7. 組態範例
      • 12.8. 測試與除錯
      • 12.9. GIN及GiST索引型別
      • 12.10. psql支援
      • 12.11. 功能限制
    • 13. 一致性管理(MVCC)
      • 13.1. 簡介
      • 13.2. 交易隔離
      • 13.3. 鎖定模式
      • 13.4. 在應用端檢視資料一致性
      • 13.5. 特別注意
      • 13.6. 鎖定與索引
    • 14. 效能技巧
      • 14.1. 善用EXPLAIN
      • 14.2. 統計資訊
      • 14.3. 使用確切的JOIN方式
      • 14.4. 快速建立資料庫內容
      • 14.5. 彈性設定
    • 15. 平行查詢
      • 15.1. 如何運作?
      • 15.2. 啓用時機?
      • 15.3. 平行查詢計畫
      • 15.4. 平行查詢的安全性
  • III. 系統管理
    • 16. 用原始碼安裝
      • 16.1. Short Version
      • 16.2. Requirements
      • 16.3. Getting The Source
      • 16.4. 安裝流程
      • 16.5. Post-Installation Setup
      • 16.6. Supported Platforms
      • 16.7. 平台相關的注意事項
    • 17. 用原始碼在 Windows 上安裝
      • 17.1. Building with Visual C++ or the Microsoft Windows SDK
    • 18. 服務配置與維運
      • 18.1. PostgreSQL 使用者帳號
      • 18.2. Creating a Database Cluster
      • 18.3. Starting the Database Server
      • 18.4. 核心資源管理
      • 18.5. Shutting Down the Server
      • 18.6. Upgrading a PostgreSQL Cluster
      • 18.7. Preventing Server Spoofing
      • 18.8. Encryption Options
      • 18.9. Secure TCP/IP Connections with SSL
      • 18.10. Secure TCP/IP Connections with SSH Tunnels
      • 18.11. 在 Windows 註冊事件日誌
    • 19. 服務組態設定
      • 19.1. Setting Parameters
      • 19.2. File Locations
      • 19.3. 連線與認證
      • 19.4. 資源配置
      • 19.5. Write Ahead Log
      • 19.6. 複寫(Replication)
      • 19.7. 查詢規畫
      • 19.8. 錯誤回報與日誌記錄
      • 19.9. Run-time Statistics
      • 19.10. 自動資料庫清理
      • 19.11. 用戶端連線預設參數
      • 19.12. 交易鎖定管理
      • 19.13. 版本與平台的相容性
      • 19.14. Error Handling
      • 19.15. 預先配置的參數
      • 19.16. Customized Options
      • 19.17. Developer Options
      • 19.18. Short Options
    • 20. 使用者認證
      • 20.1. 設定檔:pg_hba.conf
      • 20.2. User Name Maps
      • 20.3. Authentication Methods
      • 20.4. Authentication Problems
    • 21. 資料庫角色
      • 21.1. Database Roles
      • 21.2. Role Attributes
      • 21.3. Role Membership
      • 21.4. 移除角色
      • 21.5. Default Roles
      • 21.6. Function Security
    • 22. Managing Databases
      • 22.1. Overview
      • 22.2. Creating a Database
      • 22.3. 樣版資料庫
      • 22.4. Database Configuration
      • 22.5. Destroying a Database
      • 22.6. Tablespaces
    • 23. 語系
      • 23.1. 語系支援
      • 23.2. Collation Support
      • 23.3. 字元集支援
    • 24. 例行性資料庫維護工作
      • 24.1. 例行性資料清理
      • 24.2. 定期重建索引
      • 24.3. Log File Maintenance
    • 25. 備份及還原
      • 25.1. SQL Dump
      • 25.2. File System Level Backup
      • 25.3. Continuous Archiving and Point-in-Time Recovery (PITR)
    • 26. High Availability, Load Balancing, and Replication
      • 26.1. Comparison of Different Solutions
      • 26.2. 日誌轉送備用伺服器 Log-Shipping Standby Servers
      • 26.3. Failover
      • 26.4. Alternative Method for Log Shipping
      • 26.5. Hot Standby
    • 27. Recovery Configuration
      • 27.1. Archive Recovery Settings
      • 27.2. Recovery Target Settings
      • 27.3. Standby Server Settings
    • 28. 監控資料庫活動
      • 28.1. Standard Unix Tools
      • 28.2. 統計資訊收集器
      • 28.3. Viewing Locks
      • 28.4. Progress Reporting
      • 28.5. Dynamic Tracing
    • 29. Monitoring Disk Usage
      • 29.1. Determining Disk Usage
      • 29.2. Disk Full Failure
    • 30. 高可靠度及預寫日誌
      • 30.1. Reliability
      • 30.2. Write-Ahead Logging (WAL)
      • 30.3. Asynchronous Commit
      • 30.4. WAL Configuration
      • 30.5. WAL Internals
    • 31. 邏輯複寫(Logical Replication)
      • 31.1. 發佈(Publication)
      • 31.2. 訂閱(Subscription)
      • 31.3. 衝突處理
      • 31.4. 限制
      • 31.5. 架構
      • 31.6. 監控
      • 31.7. 安全性
      • 31.8. 系統設定
      • 31.9. 快速設定
    • 32. Just-in-Time Compilation (JIT)
      • 32.1. What is JIT compilation?
      • 32.2. When to JIT?
      • 32.3. Configuration
      • 32.4. Extensibility
    • 33. 迴歸測試
      • 33.1. Running the Tests
      • 33.2. Test Evaluation
      • 33.3. Variant Comparison Files
      • 33.4. TAP Tests
      • 33.5. Test Coverage Examination
  • IV. 用戶端介面
    • 34. libpq - C Library
      • 34.1. 資料庫連線控制函數
      • 34.2. 連線狀態函數
      • 34.3. Command Execution Functions
      • 34.4. Asynchronous Command Processing
      • 34.5. Retrieving Query Results Row-By-Row
      • 34.6. Canceling Queries in Progress
      • 34.7. The Fast-Path Interface
      • 34.8. Asynchronous Notification
      • 34.9. Functions Associated with the COPY Command
      • 34.10. Control Functions
      • 34.11. Miscellaneous Functions
      • 34.12. Notice Processing
      • 34.13. Event System
      • 34.14. 環境變數
      • 34.15. 密碼檔
      • 34.16. The Connection Service File
      • 34.17. LDAP Lookup of Connection Parameters
      • 34.18. SSL Support
      • 34.19. Behavior in Threaded Programs
      • 34.20. Building libpq Programs
      • 34.21. Example Programs
    • 35. Large Objects
      • 35.1. Introduction
      • 35.2. Implementation Features
      • 35.3. Client Interfaces
      • 35.4. Server-side Functions
      • 35.5. Example Program
    • 36. ECPG - Embedded SQL in C
      • 36.1. The Concept
      • 36.2. Managing Database Connections
      • 36.3. Running SQL Commands
      • 36.4. Using Host Variables
      • 36.5. Dynamic SQL
      • 36.6. pgtypes Library
      • 36.7. Using Descriptor Areas
      • 36.8. Error Handling
      • 36.9. Preprocessor Directives
      • 36.10. Processing Embedded SQL Programs
      • 36.11. Library Functions
      • 36.12. Large Objects
      • 36.13. C++ Applications
      • 36.14. Embedded SQL Commands
      • 36.15. Informix Compatibility Mode
      • 36.16. Internals
    • 37. The Information Schema
      • 37.1. The Schema
      • 37.2. Data Types
      • 37.3. information_schema_catalog_name
      • 37.4. administrable_role_authorizations
      • 37.5. applicable_roles
      • 37.6. attributes
      • 37.7. character_sets
      • 37.8. check_constraint_routine_usage
      • 37.9. check_constraints
      • 37.10. collations
      • 37.11. collation_character_set_applicability
      • 37.12. column_domain_usage
      • 37.13. column_options
      • 37.14. column_privileges
      • 37.15. column_udt_usage
      • 37.16. columns
      • 37.17. constraint_column_usage
      • 37.18. constraint_table_usage
      • 37.19. data_type_privileges
      • 37.20. domain_constraints
      • 37.21. domain_udt_usage
      • 37.22. domains
      • 37.23. element_types
      • 37.24. enabled_roles
      • 37.25. foreign_data_wrapper_options
      • 37.26. foreign_data_wrappers
      • 37.27. foreign_server_options
      • 37.28. foreign_servers
      • 37.29. foreign_table_options
      • 37.30. foreign_tables
      • 37.31. key_column_usage
      • 37.32. parameters
      • 37.33. referential_constraints
      • 37.34. role_column_grants
      • 37.35. role_routine_grants
      • 37.36. role_table_grants
      • 37.37. role_udt_grants
      • 37.38. role_usage_grants
      • 37.39. routine_privileges
      • 37.40. routines
      • 37.41. schemata
      • 37.42. sequences
      • 37.43. sql_features
      • 37.44. sql_implementation_info
      • 37.45. sql_languages
      • 37.46. sql_packages
      • 37.47. sql_parts
      • 37.48. sql_sizing
      • 37.49. sql_sizing_profiles
      • 37.50. table_constraints
      • 37.51. table_privileges
      • 37.52. tables
      • 37.53. transforms
      • 37.54. triggered_update_columns
      • 37.55. triggers
      • 37.56. udt_privileges
      • 37.57. usage_privileges
      • 37.58. user_defined_types
      • 37.59. user_mapping_options
      • 37.60. user_mappings
      • 37.61. view_column_usage
      • 37.62. view_routine_usage
      • 37.63. view_table_usage
      • 37.64. views
  • V. 資料庫程式設計
    • 38. SQL 延伸功能
      • 38.1. How Extensibility Works
      • 38.2. The PostgreSQL Type System
      • 38.3. 使用者自訂函數
      • 38.4. User-defined Procedures
      • 38.5. Query Language (SQL) Functions
      • 38.6. Function Overloading
      • 38.7. 函數易變性類別
      • 38.8. Procedural Language Functions
      • 38.9. Internal Functions
      • 38.10. C-Language Functions
      • 38.11. User-defined Aggregates
      • 38.12. User-defined Types
      • 38.13. User-defined Operators
      • 38.14. Operator Optimization Information
      • 38.15. Interfacing Extensions To Indexes
      • 38.16. Packaging Related Objects into an Extension
      • 38.17. Extension Building Infrastructure
    • 39. Triggers
    • 40. Event Triggers
    • 41. 規則系統
      • 41.1. The Query Tree
      • 41.2. Views and the Rule System
      • 41.3. Materialized Views
      • 41.4. Rules on INSERT, UPDATE, and DELETE
      • 41.5. 規則及權限
      • 41.6. Rules and Command Status
      • 41.7. Rules Versus Triggers
    • 42. Procedural Languages(程序語言)
      • 42.1. Installing Procedural Languages
    • 43. PL/pgSQL - SQL Procedural Language
      • 43.5. 基本語法
    • 44. PL/Tcl - Tcl Procedural Language
    • 45. PL/Perl - Perl Procedural Language
    • 46. PL/Python - Python Procedural Language
    • 47. Server Programming Interface
    • 48. Background Worker Processes
    • 49. Logical Decoding
    • 50. Replication Progress Tracking
  • VI. 參考資訊
    • I. SQL 指令
      • ALTER DATABASE
      • ALTER DEFAULT PRIVILEGES
      • ALTER EXTENSION
      • ALTER FUNCTION
      • ALTER INDEX
      • ALTER LANGUAGE
      • ALTER MATERIALIZED VIEW
      • ALTER POLICY
      • ALTER PUBLICATION
      • ALTER ROLE
      • ALTER RULE
      • ALTER SCHEMA
      • ALTER SEQUENCE
      • ALTER STATISTICS
      • ALTER SUBSCRIPTION
      • ALTER TABLE
      • ALTER TABLESPACE
      • ALTER TRIGGER
      • ALTER TYPE
      • ALTER VIEW
      • ANALYZE
      • CLUSTER
      • COMMENT
      • COPY
      • CREATE CAST
      • CREATE DATABASE
      • CREATE EXTENSION
      • CREATE FOREIGN TABLE
      • CREATE FOREIGN DATA WRAPPER
      • CREATE FUNCTION
      • CREATE INDEX
      • CREATE LANGUAGE
      • CREATE MATERIALIZED VIEW
      • CREATE DOMAIN
      • CREATE POLICY
      • CREATE PROCEDURE
      • CREATE PUBLICATION
      • CREATE ROLE
      • CREATE RULE
      • CREATE SCHEMA
      • CREATE SEQUENCE
      • CREATE SERVER
      • CREATE STATISTICS
      • CREATE SUBSCRIPTION
      • CREATE TABLE
      • CREATE TABLE AS
      • CREATE TABLESPACE
      • CREATE TRANSFORM
      • CREATE TRIGGER
      • CREATE TYPE
      • CREATE USER
      • CREATE USER MAPPING
      • CREATE VIEW
      • DELETE
      • DO
      • DROP DATABASE
      • DROP EXTENSION
      • DROP FUNCTION
      • DROP INDEX
      • DROP LANGUAGE
      • DROP MATERIALIZED VIEW
      • DROP OWNED
      • DROP POLICY
      • DROP ROLE
      • DROP RULE
      • DROP SCHEMA
      • DROP SEQUENCE
      • DROP STATISTICS
      • DROP SUBSCRIPTION
      • DROP TABLE
      • DROP TABLESPACE
      • DROP TRANSFORM
      • DROP TRIGGER
      • DROP TYPE
      • DROP USER
      • DROP VIEW
      • EXECUTE
      • EXPLAIN
      • GRANT
      • IMPORT FOREIGN SCHEMA
      • INSERT
      • LISTEN
      • LOAD
      • NOTIFY
      • PREPARE TRANSACTION
      • REASSIGN OWNED
      • REFRESH MATERIALIZED VIEW
      • REINDEX
      • RESET
      • REVOKE
      • SELECT
      • SELECT INTO
      • SET
      • SET CONSTRAINTS
      • SET ROLE
      • SET SESSION AUTHORIZATION
      • SET TRANSACTION
      • SHOW
      • TRUNCATE
      • UNLISTEN
      • UPDATE
      • VACUUM
      • VALUES
    • II. PostgreSQL 用戶端工具
      • createdb
      • createuser
      • dropdb
      • dropuser
      • pgbench
      • pg_dump
      • psql
      • vacuumdb
    • III. PostgreSQL 伺服器應用程式
      • pg_test_timing
      • postgres
  • VII. 資料庫進階
    • 52. 系統目錄
      • 52.3. pg_am
      • 52.7. pg_attribute
      • 52.8. pg_authid
      • 52.9. pg_auth_members
      • 52.11 pg_class
      • 52.12. pg_collation
      • 52.13. pg_constraint
      • 52.15 pg_database
      • 52.26 pg_index
      • 52.29. pg_language
      • 52.32. pg_namespace
      • 52.33. pg_opclass
      • 52.38. pg_policy
      • 52.39. pg_proc
      • 52.44. pg_rewrite
      • 52.50. pg_statistic
      • 52.51. pg_statistic_ext
      • 52.54. pg_tablespace
      • 52.56. pg_trigger
      • 52.62. pg_type
      • 52.79. pg_replication_origin_status
      • 52.81 pg_roles
      • 52.85. pg_settings
      • 52.87. pg_stats
    • 53. Frontend/Backend Protocol
      • 53.1. Overview
      • 53.2. Message Flow
      • 53.3. SASL Authentication
      • 53.4. Streaming Replication Protocol
      • 53.5. Logical Streaming Replication Protocol
      • 53.6. Message Data Types
      • 53.7. Message Formats
      • 53.8. Error and Notice Message Fields
      • 53.9. Logical Replication Message Formats
      • 53.10. Summary of Changes since Protocol 2.0
    • 54. PostgreSQL 程式撰寫慣例
      • 54.1. Formatting
      • 54.2. Reporting Errors Within the Server
      • 54.3. Error Message Style Guide
      • 54.4. Miscellaneous Coding Conventions
    • 56. Writing A Procedural Language Handler
    • 64. GiST Indexes
      • 64.1. Introduction
      • 64.2. Built-in Operator Classes
      • 64.3. Extensibility
      • 64.4. Implementation
      • 64.5. Examples
    • 65. SP-GiST Indexes
      • 65.1. Introduction
      • 65.2. Built-in Operator Classes
      • 65.3. Extensibility
      • 65.4. Implementation
      • 65.5. Examples
    • 66. GIN 索引
      • 66.1. 簡介
      • 66.2. 內建運算子類
      • 66.3. Extensibility
      • 66.4. Implementation
      • 66.5. GIN Tips and Tricks
      • 66.6. Limitations
      • 66.7. Examples
    • 67. BRIN Indexes
      • 67.1. Introduction
      • 67.2. Built-in Operator Classes
      • 67.3. Extensibility
    • 68. 資料庫實體儲存格式
      • 68.2. TOAST
      • 68.4 可視性映射表(Visibility Map)
    • 70. How the Planner Uses Statistics
      • 70.2. Multivariate Statistics Examples
  • VIII. 附錄
    • A. PostgreSQL錯誤代碼
    • B. 日期時間格式支援
      • B.1. 日期時間解譯流程
      • B.2. 日期時間慣用字
      • B.3. 日期時間設定檔
      • B.4. 日期時間的沿革
    • C. SQL 關鍵字
    • D. SQL 相容性
    • E. 版本資訊
    • F. 延伸支援模組
      • F.4. auto_explain
      • F.11. dblink
        • dblink
      • F.33. pg_visibility
    • G. Additional Supplied Programs
      • G.1. Client Applications
        • oid2name
        • vacuumlo
      • G.2. Server Applications
        • pg_standby
    • H. 外部專案
      • H.1. 用戶端介面
      • H.2. Administration Tools
      • H.3. Procedural Languages
      • H.4. Extensions
    • I. The Source Code Repository
      • I.1. Getting The Source via Git
    • J. 文件取得
    • K. 縮寫字
  • 參考書目
Powered by GitBook
On this page

Was this helpful?

Edit on Git
Export as PDF
  1. VIII. 附錄

A. PostgreSQL錯誤代碼

PreviousVIII. 附錄NextB. 日期時間格式支援

Last updated 6 years ago

Was this helpful?

所有由PostgreSQL伺服器回傳的訊息,都會搭配一個 5 個字元的錯誤代碼,這些代碼均以 SQL 標準的 SQLSTATE 代碼所定義。應用程式應該以錯誤代碼作為程式行為,而非處理文字的錯誤訊息。這些錯誤代碼會隨 PostgreSQL 版本發佈而微幅更新,但不會因為不同語言的文字訊息影響其定義。特別注意,部份錯誤代碼是以 SQL 標準的定義所制定,而有些錯誤代碼是額外制定的,以對應其他 SQL 標準未定義的使用情況。

標準來看,錯誤代碼的前 2 個字元代表著這個錯誤的類別,而後面 3 個字元則指出在此類別中更詳細的發生情況。所以,應用程式即使未完整支援特定的錯誤代碼,仍然可以依類別代碼瞭解大概發生了什麼事。

下方的 列出了所有在 PostgreSQL 10 中所定義的錯誤代碼。(部份錯誤代碼可能實際上沒有使用,但仍然依 SQL 標準所制定)每一個錯誤的類別都有一個"標準"的錯誤情況,其最後 3 個字元為 000,只用於在該類別未特別詳細定義的錯誤情況。

在"Condition Name"欄位中的內容將能在 PL/pgSQL 中被使用。Condition Name 不論大小寫字母均可合法使用。(特別注意,PL/pgSQL 並不支援 00、01 及 02 的錯誤類別。)

有一些錯誤訊息,其回傳內容是發生錯誤的資料庫物件名稱(表格 Table、表格欄位 Table column、資料型別 data type、限制條件 constraint)。舉例來說,如果產生了 unique_violation 錯誤,則會回傳某個限制條件名稱。這些訊息將會分別額外的欄位回傳,所以應用程式不需要特別解譯描述性的訊息內容。在 PostgreSQL 9.3之前,這種回傳方式僅限於 SQLSTATE 類別 23(違反限制條件的一致性 integrity constraint violation),日後將儘可能延伸支援到所有類別。

Table A.1. PostgreSQL Error Codes

Error Code

Condition Name

Class 00 — Successful Completion

00000

successful_completion

Class 01 — Warning

01000

warning

0100C

dynamic_result_sets_returned

01008

implicit_zero_bit_padding

01003

null_value_eliminated_in_set_function

01007

privilege_not_granted

01006

privilege_not_revoked

01004

string_data_right_truncation

01P01

deprecated_feature

Class 02 — No Data (this is also a warning class per the SQL standard)

02000

no_data

02001

no_additional_dynamic_result_sets_returned

Class 03 — SQL Statement Not Yet Complete

03000

sql_statement_not_yet_complete

Class 08 — Connection Exception

08000

connection_exception

08003

connection_does_not_exist

08006

connection_failure

08001

sqlclient_unable_to_establish_sqlconnection

08004

sqlserver_rejected_establishment_of_sqlconnection

08007

transaction_resolution_unknown

08P01

protocol_violation

Class 09 — Triggered Action Exception

09000

triggered_action_exception

Class 0A — Feature Not Supported

0A000

feature_not_supported

Class 0B — Invalid Transaction Initiation

0B000

invalid_transaction_initiation

Class 0F — Locator Exception

0F000

locator_exception

0F001

invalid_locator_specification

Class 0L — Invalid Grantor

0L000

invalid_grantor

0LP01

invalid_grant_operation

Class 0P — Invalid Role Specification

0P000

invalid_role_specification

Class 0Z — Diagnostics Exception

0Z000

diagnostics_exception

0Z002

stacked_diagnostics_accessed_without_active_handler

Class 20 — Case Not Found

20000

case_not_found

Class 21 — Cardinality Violation

21000

cardinality_violation

Class 22 — Data Exception

22000

data_exception

2202E

array_subscript_error

22021

character_not_in_repertoire

22008

datetime_field_overflow

22012

division_by_zero

22005

error_in_assignment

2200B

escape_character_conflict

22022

indicator_overflow

22015

interval_field_overflow

2201E

invalid_argument_for_logarithm

22014

invalid_argument_for_ntile_function

22016

invalid_argument_for_nth_value_function

2201F

invalid_argument_for_power_function

2201G

invalid_argument_for_width_bucket_function

22018

invalid_character_value_for_cast

22007

invalid_datetime_format

22019

invalid_escape_character

2200D

invalid_escape_octet

22025

invalid_escape_sequence

22P06

nonstandard_use_of_escape_character

22010

invalid_indicator_parameter_value

22023

invalid_parameter_value

2201B

invalid_regular_expression

2201W

invalid_row_count_in_limit_clause

2201X

invalid_row_count_in_result_offset_clause

2202H

invalid_tablesample_argument

2202G

invalid_tablesample_repeat

22009

invalid_time_zone_displacement_value

2200C

invalid_use_of_escape_character

2200G

most_specific_type_mismatch

22004

null_value_not_allowed

22002

null_value_no_indicator_parameter

22003

numeric_value_out_of_range

2200H

sequence_generator_limit_exceeded

22026

string_data_length_mismatch

22001

string_data_right_truncation

22011

substring_error

22027

trim_error

22024

unterminated_c_string

2200F

zero_length_character_string

22P01

floating_point_exception

22P02

invalid_text_representation

22P03

invalid_binary_representation

22P04

bad_copy_file_format

22P05

untranslatable_character

2200L

not_an_xml_document

2200M

invalid_xml_document

2200N

invalid_xml_content

2200S

invalid_xml_comment

2200T

invalid_xml_processing_instruction

Class 23 — Integrity Constraint Violation

23000

integrity_constraint_violation

23001

restrict_violation

23502

not_null_violation

23503

foreign_key_violation

23505

unique_violation

23514

check_violation

23P01

exclusion_violation

Class 24 — Invalid Cursor State

24000

invalid_cursor_state

Class 25 — Invalid Transaction State

25000

invalid_transaction_state

25001

active_sql_transaction

25002

branch_transaction_already_active

25008

held_cursor_requires_same_isolation_level

25003

inappropriate_access_mode_for_branch_transaction

25004

inappropriate_isolation_level_for_branch_transaction

25005

no_active_sql_transaction_for_branch_transaction

25006

read_only_sql_transaction

25007

schema_and_data_statement_mixing_not_supported

25P01

no_active_sql_transaction

25P02

in_failed_sql_transaction

25P03

idle_in_transaction_session_timeout

Class 26 — Invalid SQL Statement Name

26000

invalid_sql_statement_name

Class 27 — Triggered Data Change Violation

27000

triggered_data_change_violation

Class 28 — Invalid Authorization Specification

28000

invalid_authorization_specification

28P01

invalid_password

Class 2B — Dependent Privilege Descriptors Still Exist

2B000

dependent_privilege_descriptors_still_exist

2BP01

dependent_objects_still_exist

Class 2D — Invalid Transaction Termination

2D000

invalid_transaction_termination

Class 2F — SQL Routine Exception

2F000

sql_routine_exception

2F005

function_executed_no_return_statement

2F002

modifying_sql_data_not_permitted

2F003

prohibited_sql_statement_attempted

2F004

reading_sql_data_not_permitted

Class 34 — Invalid Cursor Name

34000

invalid_cursor_name

Class 38 — External Routine Exception

38000

external_routine_exception

38001

containing_sql_not_permitted

38002

modifying_sql_data_not_permitted

38003

prohibited_sql_statement_attempted

38004

reading_sql_data_not_permitted

Class 39 — External Routine Invocation Exception

39000

external_routine_invocation_exception

39001

invalid_sqlstate_returned

39004

null_value_not_allowed

39P01

trigger_protocol_violated

39P02

srf_protocol_violated

39P03

event_trigger_protocol_violated

Class 3B — Savepoint Exception

3B000

savepoint_exception

3B001

invalid_savepoint_specification

Class 3D — Invalid Catalog Name

3D000

invalid_catalog_name

Class 3F — Invalid Schema Name

3F000

invalid_schema_name

Class 40 — Transaction Rollback

40000

transaction_rollback

40002

transaction_integrity_constraint_violation

40001

serialization_failure

40003

statement_completion_unknown

40P01

deadlock_detected

Class 42 — Syntax Error or Access Rule Violation

42000

syntax_error_or_access_rule_violation

42601

syntax_error

42501

insufficient_privilege

42846

cannot_coerce

42803

grouping_error

42P20

windowing_error

42P19

invalid_recursion

42830

invalid_foreign_key

42602

invalid_name

42622

name_too_long

42939

reserved_name

42804

datatype_mismatch

42P18

indeterminate_datatype

42P21

collation_mismatch

42P22

indeterminate_collation

42809

wrong_object_type

428C9

generated_always

42703

undefined_column

42883

undefined_function

42P01

undefined_table

42P02

undefined_parameter

42704

undefined_object

42701

duplicate_column

42P03

duplicate_cursor

42P04

duplicate_database

42723

duplicate_function

42P05

duplicate_prepared_statement

42P06

duplicate_schema

42P07

duplicate_table

42712

duplicate_alias

42710

duplicate_object

42702

ambiguous_column

42725

ambiguous_function

42P08

ambiguous_parameter

42P09

ambiguous_alias

42P10

invalid_column_reference

42611

invalid_column_definition

42P11

invalid_cursor_definition

42P12

invalid_database_definition

42P13

invalid_function_definition

42P14

invalid_prepared_statement_definition

42P15

invalid_schema_definition

42P16

invalid_table_definition

42P17

invalid_object_definition

Class 44 — WITH CHECK OPTION Violation

44000

with_check_option_violation

Class 53 — Insufficient Resources

53000

insufficient_resources

53100

disk_full

53200

out_of_memory

53300

too_many_connections

53400

configuration_limit_exceeded

Class 54 — Program Limit Exceeded

54000

program_limit_exceeded

54001

statement_too_complex

54011

too_many_columns

54023

too_many_arguments

Class 55 — Object Not In Prerequisite State

55000

object_not_in_prerequisite_state

55006

object_in_use

55P02

cant_change_runtime_param

55P03

lock_not_available

55P04

unsafe_new_enum_value_usage

Class 57 — Operator Intervention

57000

operator_intervention

57014

query_canceled

57P01

admin_shutdown

57P02

crash_shutdown

57P03

cannot_connect_now

57P04

database_dropped

Class 58 — System Error (errors external toPostgreSQLitself)

58000

system_error

58030

io_error

58P01

undefined_file

58P02

duplicate_file

Class 72 — Snapshot Failure

72000

snapshot_too_old

Class F0 — Configuration File Error

F0000

config_file_error

F0001

lock_file_exists

Class HV — Foreign Data Wrapper Error (SQL/MED)

HV000

fdw_error

HV005

fdw_column_name_not_found

HV002

fdw_dynamic_parameter_value_needed

HV010

fdw_function_sequence_error

HV021

fdw_inconsistent_descriptor_information

HV024

fdw_invalid_attribute_value

HV007

fdw_invalid_column_name

HV008

fdw_invalid_column_number

HV004

fdw_invalid_data_type

HV006

fdw_invalid_data_type_descriptors

HV091

fdw_invalid_descriptor_field_identifier

HV00B

fdw_invalid_handle

HV00C

fdw_invalid_option_index

HV00D

fdw_invalid_option_name

HV090

fdw_invalid_string_length_or_buffer_length

HV00A

fdw_invalid_string_format

HV009

fdw_invalid_use_of_null_pointer

HV014

fdw_too_many_handles

HV001

fdw_out_of_memory

HV00P

fdw_no_schemas

HV00J

fdw_option_name_not_found

HV00K

fdw_reply_handle

HV00Q

fdw_schema_not_found

HV00R

fdw_table_not_found

HV00L

fdw_unable_to_create_execution

HV00M

fdw_unable_to_create_reply

HV00N

fdw_unable_to_establish_connection

Class P0 — PL/pgSQL Error

P0000

plpgsql_error

P0001

raise_exception

P0002

no_data_found

P0003

too_many_rows

P0004

assert_failure

Class XX — Internal Error

XX000

internal_error

XX001

data_corrupted

XX002

index_corrupted

https://www.postgresql.org/docs/10/static/errcodes-appendix.html
Table A.1