使用将查询结果创建数据表

最近更新时间: 2025-02-18 16:02:00

  • 复制
    复制成功
postgres=# create table t(id int,mc text) distribute by shard(mc);
CREATE TABLE
postgres=# insert into t values(1,'TDSQL PG');
INSERT 0 1
postgres=#  create table t_as as select * from t;
INSERT 0 1
postgres=# select * from t_as;
 id |  mc   
----+-------
  1 | TDSQL PG
(1 row)

postgres=# \d+ t
                                      Table "tbase.t"
 Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
--------+---------+-----------+----------+---------+----------+--------------+-------------
 id     | integer |           |          |         | plain    |              | 
 mc     | text    |           |          |         | extended |              | 
Distribute By: SHARD(mc)
Location Nodes: ALL DATANODES


postgres=# \d+ t_as
                                    Table "tbase.t_as"
 Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
--------+---------+-----------+----------+---------+----------+--------------+-------------
 id     | integer |           |          |         | plain    |              | 
 mc     | text    |           |          |         | extended |              | 
Distribute By: SHARD(id)
Location Nodes: ALL DATANODES

postgres=#