PostgreSQLは、新しいテーブルを作成するためのテンプレートとして、他のテーブルを使用しています

新しいテーブルを作成するためのテンプレートとして、他のテーブルの使用

テーブルを作成tbl_bigすばやくテーブルを作成するためのテンプレートとして、テーブルを使用して( like tbl_big including all )

[root@uzong ~]# su postgres
bash-4.2$ psql technology
could not change directory to "/root"
psql (9.2.24, server 10.8)
WARNING: psql version 9.2, server version 10.0.
         Some psql features might not work.
Type "help" for help.

technology=# create table tbl_big (
technology(# id int primary key, 
technology(# info text, 
technology(# crt_time timestamp
technology(# );
CREATE TABLE
technology=# create index idx_tbl_big on tbl_big (crt_time); 
CREATE INDEX
technology=# \d tbl_big;
               Table "public.tbl_big"
  Column  |            Type             | Modifiers 
----------+-----------------------------+-----------
 id       | integer                     | not null
 info     | text                        | 
 crt_time | timestamp without time zone | 
Indexes:
    "tbl_big_pkey" PRIMARY KEY, btree (id)
    "idx_tbl_big" btree (crt_time)

technology=# create table tbl ( like tbl_big including all );
CREATE TABLE
technology=# \d tbl;
                 Table "public.tbl"
  Column  |            Type             | Modifiers 
----------+-----------------------------+-----------
 id       | integer                     | not null
 info     | text                        | 
 crt_time | timestamp without time zone | 
Indexes:
    "tbl_pkey" PRIMARY KEY, btree (id)
    "tbl_crt_time_idx" btree (crt_time)

( like tbl_big including all )迅速に解体(等インデックス情報、プライマリーキーを含む)テーブルのコピー

その他のパラメータ:

including defults

including constraints

including indexes

including storage

including comments

including all  -- 全部

概要

承継のための新しいテーブルのアプリケーションシナリオを作成するためのテンプレートとして、他のテーブルを使用するには、テーブル、コピー、などを指し

公開された274元の記事 ウォンの賞賛119 ビュー290 000 +

おすすめ

転載: blog.csdn.net/qq_31156277/article/details/98516962