she*_*eeb 1 postgresql database-partitioning
CREATE TABLE countrymeasurements
(
countrycode int NOT NULL,
countryname character varying(30) NOT NULL,
languagename character varying (30) NOT NULL,
daysofoperation character varying(30) NOT NULL,
salesparts bigint,
replaceparts bigint
)
PARTITION BY LIST(countrycode)
(
partition india values(1),
partition japan values(2),
partition china values(3),
partition malaysia values(4)
);
Run Code Online (Sandbox Code Playgroud)
我收到错误:“(”处或附近的语法错误。我在这里缺少什么。我正在使用 postgres12
我不知道您在哪里找到该语法,显然手册中没有。如您所见,create table .. as partition of在 Postgres 中使用创建了分区:
定义表:
CREATE TABLE countrymeasurements
(
countrycode int NOT NULL,
countryname character varying(30) NOT NULL,
languagename character varying (30) NOT NULL,
daysofoperation character varying(30) NOT NULL,
salesparts bigint,
replaceparts bigint
)
PARTITION BY LIST(countrycode);
Run Code Online (Sandbox Code Playgroud)
定义分区:
create table india
partition of countrymeasurements
for values in (1);
create table japan
partition of countrymeasurements
for values in (2);
create table china
partition of countrymeasurements
for values in (3);
create table malaysia
partition of countrymeasurements
for values in (4);
Run Code Online (Sandbox Code Playgroud)