我正在使用带有Oracle Compatibilty的Enterprise Postgres。这是我在数据库中创建的表。
CREATE TABLE ALL_COUNTRIES
(
COUNTRY_ID numeric(20,0),
CHARACTERISTIC_NAME character varying(255)
)
PARTITION BY LIST (COUNTRY_ID)
(
PARTITION COUNTRY VALUES (484, 170, 76, 360, 710) TABLESPACE my_tbs
);
创建了两个表。一个是主表,另一个是分区表。
主表:
CREATE TABLE cdar_panel.all_countries
(
country_id numeric(20,0),
characteristic_name character varying(255)
)
分区表:
CREATE TABLE cdar_panel.all_countries_country
(
country_id ,
characteristic_name ,
CONSTRAINT all_countries_country_partition CHECK ((country_id = ANY (ARRAY['484'::numeric(20,0), '170'::numeric(20,0), '76'::numeric(20,0), '360'::numeric(20,0), '710'::numeric(20,0)])) AND country_id IS NOT NULL)
)
INHERITS (cdar_panel.all_countries)
我想要做的就是在CHECK约束中再添加两个字段。我可以知道该怎么做。
它不允许我这样做 改变约束。 2.不能掉落“只有分区”。 3.无法再添加一个约束并删除原始约束。
请帮忙。
答案 0 :(得分:0)
The example that follows deletes a partition of the sales table. Use the following command to create the sales table:
CREATE TABLE sales
(
dept_no number,
part_no varchar2,
country varchar2(20),
date date,
amount number
)
PARTITION BY LIST(country)
(
PARTITION europe VALUES('FRANCE', 'ITALY'),
PARTITION asia VALUES('INDIA', 'PAKISTAN'),
PARTITION americas VALUES('US', 'CANADA')
);
Querying the ALL_TAB_PARTITIONS view displays the partition names:
acctg=# SELECT partition_name, server_name, high_value FROM ALL_TAB_PARTITIONS;
partition_name | server_name | high_value
----------------+-------------+---------------------
europe | seattle | 'FRANCE', 'ITALY'
asia | chicago | 'INDIA', 'PAKISTAN'
americas | boston | 'US', 'CANADA'
(3 rows)
To delete the americas partition from the sales table, invoke the following command:
ALTER TABLE sales DROP PARTITION americas;
Querying the ALL_TAB_PARTITIONS view demonstrates that the partition has been successfully deleted:
acctg=# SELECT partition_name, server_name, high_value FROM ALL_TAB_PARTITIONS;
partition_name | high_value
----------------+---------------------
asia | 'INDIA', 'PAKISTAN'
europe | 'FRANCE', 'ITALY'
(2 rows)
我希望这会有助于删除分区:)