如何用子表重命名分区表

问题描述 投票:0回答:1

我正在尝试重命名分区中的父表。我按年度创建了3个子表。我可以更改父表的名称,但是我不知道如何更改3个子表的引用。

这是我的分区表结构。

CREATE TABLE IF NOT EXISTS test_demos(
id bigserial NOT NULL,  
partition_by integer NOT NULL,
names character varying (80) NOT NULL,
age integer,
aed character varying (5) NOT NULL,
entered_user_id integer,
entered_post_id integer,
entered_office_id integer,
dept_code character varying (25) NOT NULL,
owner_dept_code character varying (25) NOT NULL,
approval character varying (5) NOT NULL,
which inet,
whom macaddr,
who character varying(50),
row_created_at timestamp(0) WITHOUT TIME ZONE NOT NULL DEFAULT 
CURRENT_TIMESTAMP)
PARTITION BY LIST(partition_by);

CREATE TABLE IF NOT EXISTS test_demos2019s PARTITION OF test_demos FOR VALUES IN (2019);

CREATE TABLE IF NOT EXISTS test_demos2020s PARTITION OF test_demos FOR VALUES IN (2020);

CREATE TABLE IF NOT EXISTS test_demos2021s PARTITION OF test_demos FOR VALUES IN (2021);
mysql postgresql laravel-5 postgresql-9.1 php-pgsql
1个回答
0
投票

您好Sunitha,

更改表名的语法是,

alter table table_name to new_table_name;

在您的情况下,

alter table test_demos2019s to new_table_name;
alter table test_demos2020s to new_table_name;
alter table test_demos2021s to new_table_name;
© www.soinside.com 2019 - 2024. All rights reserved.