表相关操作
最近更新时间: 2024-10-17 17:10:00
- 建立数据表。
postgres=# create table tbase(id int,mc text) distribute by shard(id);
CREATE TABLE
- \d查看表结构,包括使用的触发器。
postgres=# \d tbase
Table"public.tbase"
Column | Type | Modifiers
--------+---------+-----------
id |integer |
mc |text |
- \d+查看表结构(包含注释),表类型,分布节点。
postgres=# \d+ tbase
Table"public.tbase"
Column | Type |Modifiers | Storage | Stats target |Description
--------+---------+-----------+----------+--------------+-------------
id |integer | | plain | |
mc |text | | extended | |
Has OIDs: no
Distribute By SHARD(id)
Location Nodes: ALL DATANODES
- \dt查看表列表。
postgres=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------------+-------+-------
public | t_time_range | table | tbase
public | tbase | table | tbase
(2 rows)
\dt+查看表列表详细信息,包含表大小和注释。
这里连接的节点如果是cn的话,表大小为所有dn节点大小之和,否则为只是该节点的表大小。
postgres=# \dt+
List of relations
Schema| Name | Type | Owner | Size | Description
--------+--------------+-------+-------+---------+--------------------
public | t_time_range | table | tbase | 0 bytes | 这是一个日期分区表
public | tbase | table | tbase | 576 kB |
(2 rows)
- \dt+显示某个模式下的所有表。
postgres=# \dt+ pgxc.*
List of relations
Schema| Name | Type | Owner | Size | Description
--------+------------+-------+-------+---------+-------------
pgxc |order_main | table | tbase | 0 bytes |
(1 row)
- \dt+表名显示某个表的详细信息。
postgres=# \dt+ tbase
List of relations
Schema| Name | Type | Owner | Size | Description
--------+-------+-------+-------+--------+-------------
public | tbase | table | tbase | 576 kB |
(1 row)
- \dt+通配符列出适配的表。
postgres=# \dt+ t*
List of relations
Schema| Name | Type | Owner | Size | Description
--------+--------------+-------+-------+---------+--------------------
public | t_time_range | table | tbase | 0 bytes | 这是一个日期分区表
public | tbase | table | tbase | 576 kB |
(2 rows)
postgres=# \dt+ t_*
List of relations
Schema| Name | Type | Owner | Size | Description
--------+--------------+-------+-------+---------+--------------------
public | t_time_range | table | tbase | 0 bytes | 这是一个日期分区表
(1 row)
- \det 列出外部表 。
postgres=# \det
List of foreign tables
Schema | Table | Server
--------+-------------+-----------------
public | t_table_csv | exttable_server
(1 row)