pg_attribute

存储对象列信息的系统表

pg_attribute 是一个存储数据库对象列信息的系统目录表。

pg_attribute 一直存在于 PostgreSQL 中。

按 PostgreSQL 版本定义

pg_attribute (PostgreSQL 17)

               Table "pg_catalog.pg_attribute"
     Column     |   Type    | Collation | Nullable | Default 
----------------+-----------+-----------+----------+---------
 attrelid       | oid       |           | not null | 
 attname        | name      |           | not null | 
 atttypid       | oid       |           | not null | 
 attlen         | smallint  |           | not null | 
 attnum         | smallint  |           | not null | 
 attcacheoff    | integer   |           | not null | 
 atttypmod      | integer   |           | not null | 
 attndims       | smallint  |           | not null | 
 attbyval       | boolean   |           | not null | 
 attalign       | "char"    |           | not null | 
 attstorage     | "char"    |           | not null | 
 attcompression | "char"    |           | not null | 
 attnotnull     | boolean   |           | not null | 
 atthasdef      | boolean   |           | not null | 
 atthasmissing  | boolean   |           | not null | 
 attidentity    | "char"    |           | not null | 
 attgenerated   | "char"    |           | not null | 
 attisdropped   | boolean   |           | not null | 
 attislocal     | boolean   |           | not null | 
 attinhcount    | smallint  |           | not null | 
 attcollation   | oid       |           | not null | 
 attstattarget  | smallint  |           |          | 
 attacl         | aclitem[] |           |          | 
 attoptions     | text[]    | C         |          | 
 attfdwoptions  | text[]    | C         |          | 
 attmissingval  | anyarray  |           |          | 
Indexes:
    "pg_attribute_relid_attnum_index" PRIMARY KEY, btree (attrelid, attnum)
    "pg_attribute_relid_attnam_index" UNIQUE CONSTRAINT, btree (attrelid, attname)
    

文档: pg_attribute

pg_attribute (PostgreSQL 16)

               Table "pg_catalog.pg_attribute"
     Column     |   Type    | Collation | Nullable | Default 
----------------+-----------+-----------+----------+---------
 attrelid       | oid       |           | not null | 
 attname        | name      |           | not null | 
 atttypid       | oid       |           | not null | 
 attlen         | smallint  |           | not null | 
 attnum         | smallint  |           | not null | 
 attcacheoff    | integer   |           | not null | 
 atttypmod      | integer   |           | not null | 
 attndims       | smallint  |           | not null | 
 attbyval       | boolean   |           | not null | 
 attalign       | "char"    |           | not null | 
 attstorage     | "char"    |           | not null | 
 attcompression | "char"    |           | not null | 
 attnotnull     | boolean   |           | not null | 
 atthasdef      | boolean   |           | not null | 
 atthasmissing  | boolean   |           | not null | 
 attidentity    | "char"    |           | not null | 
 attgenerated   | "char"    |           | not null | 
 attisdropped   | boolean   |           | not null | 
 attislocal     | boolean   |           | not null | 
 attinhcount    | smallint  |           | not null | 
 attstattarget  | smallint  |           | not null | 
 attcollation   | oid       |           | not null | 
 attacl         | aclitem[] |           |          | 
 attoptions     | text[]    | C         |          | 
 attfdwoptions  | text[]    | C         |          | 
 attmissingval  | anyarray  |           |          | 
Indexes:
    "pg_attribute_relid_attnum_index" PRIMARY KEY, btree (attrelid, attnum)
    "pg_attribute_relid_attnam_index" UNIQUE CONSTRAINT, btree (attrelid, attname)
    

文档: pg_attribute

pg_attribute (PostgreSQL 15)

               Table "pg_catalog.pg_attribute"
     Column     |   Type    | Collation | Nullable | Default 
----------------+-----------+-----------+----------+---------
 attrelid       | oid       |           | not null | 
 attname        | name      |           | not null | 
 atttypid       | oid       |           | not null | 
 attstattarget  | integer   |           | not null | 
 attlen         | smallint  |           | not null | 
 attnum         | smallint  |           | not null | 
 attndims       | integer   |           | not null | 
 attcacheoff    | integer   |           | not null | 
 atttypmod      | integer   |           | not null | 
 attbyval       | boolean   |           | not null | 
 attalign       | "char"    |           | not null | 
 attstorage     | "char"    |           | not null | 
 attcompression | "char"    |           | not null | 
 attnotnull     | boolean   |           | not null | 
 atthasdef      | boolean   |           | not null | 
 atthasmissing  | boolean   |           | not null | 
 attidentity    | "char"    |           | not null | 
 attgenerated   | "char"    |           | not null | 
 attisdropped   | boolean   |           | not null | 
 attislocal     | boolean   |           | not null | 
 attinhcount    | integer   |           | not null | 
 attcollation   | oid       |           | not null | 
 attacl         | aclitem[] |           |          | 
 attoptions     | text[]    | C         |          | 
 attfdwoptions  | text[]    | C         |          | 
 attmissingval  | anyarray  |           |          | 
Indexes:
    "pg_attribute_relid_attnum_index" PRIMARY KEY, btree (attrelid, attnum)
    "pg_attribute_relid_attnam_index" UNIQUE CONSTRAINT, btree (attrelid, attname)
    

文档: pg_attribute

pg_attribute (PostgreSQL 14)

               Table "pg_catalog.pg_attribute"
     Column     |   Type    | Collation | Nullable | Default 
----------------+-----------+-----------+----------+---------
 attrelid       | oid       |           | not null | 
 attname        | name      |           | not null | 
 atttypid       | oid       |           | not null | 
 attstattarget  | integer   |           | not null | 
 attlen         | smallint  |           | not null | 
 attnum         | smallint  |           | not null | 
 attndims       | integer   |           | not null | 
 attcacheoff    | integer   |           | not null | 
 atttypmod      | integer   |           | not null | 
 attbyval       | boolean   |           | not null | 
 attalign       | "char"    |           | not null | 
 attstorage     | "char"    |           | not null | 
 attcompression | "char"    |           | not null | 
 attnotnull     | boolean   |           | not null | 
 atthasdef      | boolean   |           | not null | 
 atthasmissing  | boolean   |           | not null | 
 attidentity    | "char"    |           | not null | 
 attgenerated   | "char"    |           | not null | 
 attisdropped   | boolean   |           | not null | 
 attislocal     | boolean   |           | not null | 
 attinhcount    | integer   |           | not null | 
 attcollation   | oid       |           | not null | 
 attacl         | aclitem[] |           |          | 
 attoptions     | text[]    | C         |          | 
 attfdwoptions  | text[]    | C         |          | 
 attmissingval  | anyarray  |           |          | 
Indexes:
    "pg_attribute_relid_attnum_index" PRIMARY KEY, btree (attrelid, attnum)
    "pg_attribute_relid_attnam_index" UNIQUE CONSTRAINT, btree (attrelid, attname)
    

文档: pg_attribute

pg_attribute (PostgreSQL 13)

              Table "pg_catalog.pg_attribute"
    Column     |   Type    | Collation | Nullable | Default 
---------------+-----------+-----------+----------+---------
 attrelid      | oid       |           | not null | 
 attname       | name      |           | not null | 
 atttypid      | oid       |           | not null | 
 attstattarget | integer   |           | not null | 
 attlen        | smallint  |           | not null | 
 attnum        | smallint  |           | not null | 
 attndims      | integer   |           | not null | 
 attcacheoff   | integer   |           | not null | 
 atttypmod     | integer   |           | not null | 
 attbyval      | boolean   |           | not null | 
 attstorage    | "char"    |           | not null | 
 attalign      | "char"    |           | not null | 
 attnotnull    | boolean   |           | not null | 
 atthasdef     | boolean   |           | not null | 
 atthasmissing | boolean   |           | not null | 
 attidentity   | "char"    |           | not null | 
 attgenerated  | "char"    |           | not null | 
 attisdropped  | boolean   |           | not null | 
 attislocal    | boolean   |           | not null | 
 attinhcount   | integer   |           | not null | 
 attcollation  | oid       |           | not null | 
 attacl        | aclitem[] |           |          | 
 attoptions    | text[]    | C         |          | 
 attfdwoptions | text[]    | C         |          | 
 attmissingval | anyarray  |           |          | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 12)

              Table "pg_catalog.pg_attribute"
    Column     |   Type    | Collation | Nullable | Default 
---------------+-----------+-----------+----------+---------
 attrelid      | oid       |           | not null | 
 attname       | name      |           | not null | 
 atttypid      | oid       |           | not null | 
 attstattarget | integer   |           | not null | 
 attlen        | smallint  |           | not null | 
 attnum        | smallint  |           | not null | 
 attndims      | integer   |           | not null | 
 attcacheoff   | integer   |           | not null | 
 atttypmod     | integer   |           | not null | 
 attbyval      | boolean   |           | not null | 
 attstorage    | "char"    |           | not null | 
 attalign      | "char"    |           | not null | 
 attnotnull    | boolean   |           | not null | 
 atthasdef     | boolean   |           | not null | 
 atthasmissing | boolean   |           | not null | 
 attidentity   | "char"    |           | not null | 
 attgenerated  | "char"    |           | not null | 
 attisdropped  | boolean   |           | not null | 
 attislocal    | boolean   |           | not null | 
 attinhcount   | integer   |           | not null | 
 attcollation  | oid       |           | not null | 
 attacl        | aclitem[] |           |          | 
 attoptions    | text[]    | C         |          | 
 attfdwoptions | text[]    | C         |          | 
 attmissingval | anyarray  |           |          | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 11)

              Table "pg_catalog.pg_attribute"
    Column     |   Type    | Collation | Nullable | Default 
---------------+-----------+-----------+----------+---------
 attrelid      | oid       |           | not null | 
 attname       | name      |           | not null | 
 atttypid      | oid       |           | not null | 
 attstattarget | integer   |           | not null | 
 attlen        | smallint  |           | not null | 
 attnum        | smallint  |           | not null | 
 attndims      | integer   |           | not null | 
 attcacheoff   | integer   |           | not null | 
 atttypmod     | integer   |           | not null | 
 attbyval      | boolean   |           | not null | 
 attstorage    | "char"    |           | not null | 
 attalign      | "char"    |           | not null | 
 attnotnull    | boolean   |           | not null | 
 atthasdef     | boolean   |           | not null | 
 atthasmissing | boolean   |           | not null | 
 attidentity   | "char"    |           | not null | 
 attisdropped  | boolean   |           | not null | 
 attislocal    | boolean   |           | not null | 
 attinhcount   | integer   |           | not null | 
 attcollation  | oid       |           | not null | 
 attacl        | aclitem[] |           |          | 
 attoptions    | text[]    |           |          | 
 attfdwoptions | text[]    |           |          | 
 attmissingval | anyarray  |           |          | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 10)

              Table "pg_catalog.pg_attribute"
    Column     |   Type    | Collation | Nullable | Default 
---------------+-----------+-----------+----------+---------
 attrelid      | oid       |           | not null | 
 attname       | name      |           | not null | 
 atttypid      | oid       |           | not null | 
 attstattarget | integer   |           | not null | 
 attlen        | smallint  |           | not null | 
 attnum        | smallint  |           | not null | 
 attndims      | integer   |           | not null | 
 attcacheoff   | integer   |           | not null | 
 atttypmod     | integer   |           | not null | 
 attbyval      | boolean   |           | not null | 
 attstorage    | "char"    |           | not null | 
 attalign      | "char"    |           | not null | 
 attnotnull    | boolean   |           | not null | 
 atthasdef     | boolean   |           | not null | 
 attidentity   | "char"    |           | not null | 
 attisdropped  | boolean   |           | not null | 
 attislocal    | boolean   |           | not null | 
 attinhcount   | integer   |           | not null | 
 attcollation  | oid       |           | not null | 
 attacl        | aclitem[] |           |          | 
 attoptions    | text[]    |           |          | 
 attfdwoptions | text[]    |           |          | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 9.6)

    Table "pg_catalog.pg_attribute"
    Column     |   Type    | Modifiers 
---------------+-----------+-----------
 attrelid      | oid       | not null
 attname       | name      | not null
 atttypid      | oid       | not null
 attstattarget | integer   | not null
 attlen        | smallint  | not null
 attnum        | smallint  | not null
 attndims      | integer   | not null
 attcacheoff   | integer   | not null
 atttypmod     | integer   | not null
 attbyval      | boolean   | not null
 attstorage    | "char"    | not null
 attalign      | "char"    | not null
 attnotnull    | boolean   | not null
 atthasdef     | boolean   | not null
 attisdropped  | boolean   | not null
 attislocal    | boolean   | not null
 attinhcount   | integer   | not null
 attcollation  | oid       | not null
 attacl        | aclitem[] | 
 attoptions    | text[]    | 
 attfdwoptions | text[]    | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 9.5)

    Table "pg_catalog.pg_attribute"
    Column     |   Type    | Modifiers 
---------------+-----------+-----------
 attrelid      | oid       | not null
 attname       | name      | not null
 atttypid      | oid       | not null
 attstattarget | integer   | not null
 attlen        | smallint  | not null
 attnum        | smallint  | not null
 attndims      | integer   | not null
 attcacheoff   | integer   | not null
 atttypmod     | integer   | not null
 attbyval      | boolean   | not null
 attstorage    | "char"    | not null
 attalign      | "char"    | not null
 attnotnull    | boolean   | not null
 atthasdef     | boolean   | not null
 attisdropped  | boolean   | not null
 attislocal    | boolean   | not null
 attinhcount   | integer   | not null
 attcollation  | oid       | not null
 attacl        | aclitem[] | 
 attoptions    | text[]    | 
 attfdwoptions | text[]    | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 9.4)

    Table "pg_catalog.pg_attribute"
    Column     |   Type    | Modifiers 
---------------+-----------+-----------
 attrelid      | oid       | not null
 attname       | name      | not null
 atttypid      | oid       | not null
 attstattarget | integer   | not null
 attlen        | smallint  | not null
 attnum        | smallint  | not null
 attndims      | integer   | not null
 attcacheoff   | integer   | not null
 atttypmod     | integer   | not null
 attbyval      | boolean   | not null
 attstorage    | "char"    | not null
 attalign      | "char"    | not null
 attnotnull    | boolean   | not null
 atthasdef     | boolean   | not null
 attisdropped  | boolean   | not null
 attislocal    | boolean   | not null
 attinhcount   | integer   | not null
 attcollation  | oid       | not null
 attacl        | aclitem[] | 
 attoptions    | text[]    | 
 attfdwoptions | text[]    | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 9.3)

    Table "pg_catalog.pg_attribute"
    Column     |   Type    | Modifiers 
---------------+-----------+-----------
 attrelid      | oid       | not null
 attname       | name      | not null
 atttypid      | oid       | not null
 attstattarget | integer   | not null
 attlen        | smallint  | not null
 attnum        | smallint  | not null
 attndims      | integer   | not null
 attcacheoff   | integer   | not null
 atttypmod     | integer   | not null
 attbyval      | boolean   | not null
 attstorage    | "char"    | not null
 attalign      | "char"    | not null
 attnotnull    | boolean   | not null
 atthasdef     | boolean   | not null
 attisdropped  | boolean   | not null
 attislocal    | boolean   | not null
 attinhcount   | integer   | not null
 attcollation  | oid       | not null
 attacl        | aclitem[] | 
 attoptions    | text[]    | 
 attfdwoptions | text[]    | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 9.2)

    Table "pg_catalog.pg_attribute"
    Column     |   Type    | Modifiers 
---------------+-----------+-----------
 attrelid      | oid       | not null
 attname       | name      | not null
 atttypid      | oid       | not null
 attstattarget | integer   | not null
 attlen        | smallint  | not null
 attnum        | smallint  | not null
 attndims      | integer   | not null
 attcacheoff   | integer   | not null
 atttypmod     | integer   | not null
 attbyval      | boolean   | not null
 attstorage    | "char"    | not null
 attalign      | "char"    | not null
 attnotnull    | boolean   | not null
 atthasdef     | boolean   | not null
 attisdropped  | boolean   | not null
 attislocal    | boolean   | not null
 attinhcount   | integer   | not null
 attcollation  | oid       | not null
 attacl        | aclitem[] | 
 attoptions    | text[]    | 
 attfdwoptions | text[]    | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 9.1)

    Table "pg_catalog.pg_attribute"
    Column     |   Type    | Modifiers 
---------------+-----------+-----------
 attrelid      | oid       | not null
 attname       | name      | not null
 atttypid      | oid       | not null
 attstattarget | integer   | not null
 attlen        | smallint  | not null
 attnum        | smallint  | not null
 attndims      | integer   | not null
 attcacheoff   | integer   | not null
 atttypmod     | integer   | not null
 attbyval      | boolean   | not null
 attstorage    | "char"    | not null
 attalign      | "char"    | not null
 attnotnull    | boolean   | not null
 atthasdef     | boolean   | not null
 attisdropped  | boolean   | not null
 attislocal    | boolean   | not null
 attinhcount   | integer   | not null
 attcollation  | oid       | not null
 attacl        | aclitem[] | 
 attoptions    | text[]    | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 9.0)

    Table "pg_catalog.pg_attribute"
    Column     |   Type    | Modifiers 
---------------+-----------+-----------
 attrelid      | oid       | not null
 attname       | name      | not null
 atttypid      | oid       | not null
 attstattarget | integer   | not null
 attlen        | smallint  | not null
 attnum        | smallint  | not null
 attndims      | integer   | not null
 attcacheoff   | integer   | not null
 atttypmod     | integer   | not null
 attbyval      | boolean   | not null
 attstorage    | "char"    | not null
 attalign      | "char"    | not null
 attnotnull    | boolean   | not null
 atthasdef     | boolean   | not null
 attisdropped  | boolean   | not null
 attislocal    | boolean   | not null
 attinhcount   | integer   | not null
 attacl        | aclitem[] | 
 attoptions    | text[]    | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 8.4)

    Table "pg_catalog.pg_attribute"
    Column     |   Type    | Modifiers 
---------------+-----------+-----------
 attrelid      | oid       | not null
 attname       | name      | not null
 atttypid      | oid       | not null
 attstattarget | integer   | not null
 attlen        | smallint  | not null
 attnum        | smallint  | not null
 attndims      | integer   | not null
 attcacheoff   | integer   | not null
 atttypmod     | integer   | not null
 attbyval      | boolean   | not null
 attstorage    | "char"    | not null
 attalign      | "char"    | not null
 attnotnull    | boolean   | not null
 atthasdef     | boolean   | not null
 attisdropped  | boolean   | not null
 attislocal    | boolean   | not null
 attinhcount   | integer   | not null
 attacl        | aclitem[] | 
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 8.3)

   Table "pg_catalog.pg_attribute"
    Column     |   Type   | Modifiers 
---------------+----------+-----------
 attrelid      | oid      | not null
 attname       | name     | not null
 atttypid      | oid      | not null
 attstattarget | integer  | not null
 attlen        | smallint | not null
 attnum        | smallint | not null
 attndims      | integer  | not null
 attcacheoff   | integer  | not null
 atttypmod     | integer  | not null
 attbyval      | boolean  | not null
 attstorage    | "char"   | not null
 attalign      | "char"   | not null
 attnotnull    | boolean  | not null
 atthasdef     | boolean  | not null
 attisdropped  | boolean  | not null
 attislocal    | boolean  | not null
 attinhcount   | integer  | not null
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

pg_attribute (PostgreSQL 8.2)

   Table "pg_catalog.pg_attribute"
    Column     |   Type   | Modifiers 
---------------+----------+-----------
 attrelid      | oid      | not null
 attname       | name     | not null
 atttypid      | oid      | not null
 attstattarget | integer  | not null
 attlen        | smallint | not null
 attnum        | smallint | not null
 attndims      | integer  | not null
 attcacheoff   | integer  | not null
 atttypmod     | integer  | not null
 attbyval      | boolean  | not null
 attstorage    | "char"   | not null
 attalign      | "char"   | not null
 attnotnull    | boolean  | not null
 atthasdef     | boolean  | not null
 attisdropped  | boolean  | not null
 attislocal    | boolean  | not null
 attinhcount   | integer  | not null
Indexes:
    "pg_attribute_relid_attnam_index" UNIQUE, btree (attrelid, attname)
    "pg_attribute_relid_attnum_index" UNIQUE, btree (attrelid, attnum)
    

文档: pg_attribute

更改历史记录

示例

简单单列表的 pg_attribute 示例内容

postgres=# CREATE TABLE foo (id INT NOT NULL);
CREATE TABLE

postgres=# SELECT * FROM pg_attribute WHERE attrelid='foo'::regclass AND attnum > 0;
-[ RECORD 1 ]--+------
attrelid       | 16418
attname        | id
atttypid       | 23
attstattarget  | -1
attlen         | 4
attnum         | 1
attndims       | 0
attcacheoff    | -1
atttypmod      | -1
attbyval       | t
attstorage     | p
attalign       | i
attnotnull     | t
atthasdef      | f
atthasmissing  | f
attidentity    | 
attgenerated   | 
attisdropped   | f
attislocal     | t
attinhcount    | 0
attcollation   | 0
attcompression | 
attacl         | 
attoptions     | 
attfdwoptions  | 
attmissingval  | 

分类

系统目录

另请参阅

pg_attrdefpg_class

反馈

提交关于"pg_attribute"的任何评论、建议或更正 此处