mysql - 如何用子表重命名分区表
问题描述
我正在尝试重命名分区中的父表。我按年创建了 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);
解决方案
在 PostgreSQL 中,这就像我认为的那样有效。
ALTER TABLE test_demos2019s RENAME TO new_table_name;
ALTER TABLE test_demos2020s RENAME TO new_table_name2;
ALTER TABLE test_demos2021s RENAME TO new_table_name3;
推荐阅读
- javascript - 如何每天只刷新一次页面(加载页面后)单击按钮并使用Javascript打印上次刷新的时间
- java - 我有一个错误 NetworkDispatcher.processRequest
- python - Plotly-Dash:如何使用仍然显示原始列名的交叉表制作数据框?
- eslint - 你能用不同的语言对文件的一部分进行 Lint 吗?
- python - 删除控制台中的最后一行以编写更短的消息 python
- json - JSONDecoder 未从 api 加载文本
- android - 获取 ANativeWindow_lock 错误代码的描述
- ios - 如何在 Swift 中为导航栏添加阴影并隐藏边框?
- python-3.x - 将模块从子文件夹导入python3x中的不同子文件夹
- javascript - Angular - 在面包屑中使用参数