[odb-users] PostgreSQL declarative partitioning - generated
schema file
Attilio Priolo
attilio.priolo at gmail.com
Mon May 3 08:21:22 EDT 2021
Hello Boris,
Thank you for your prompt reply.
Let me show you an example:
- Original generated schema file
...
CREATE TABLE "event_log" (
"id_timestamp" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"id_id" BIGSERIAL NOT NULL,
"typeid" TEXT NOT NULL,
"timestamp" TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
"ept" BIGINT NULL,
PRIMARY KEY ("id_timestamp",
"id_id"),
CONSTRAINT "ept_fk"
FOREIGN KEY ("ept")
REFERENCES "ept" ("id")
INITIALLY DEFERRED);
...
The modified version to be used as declarative partitioning parent table is
the following:
CREATE TABLE "event_log" (
"id_timestamp" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"id_id" BIGSERIAL NOT NULL,
"typeid" TEXT NOT NULL,
"timestamp" TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
"ept" BIGINT NULL,
PRIMARY KEY ("id_timestamp",
"id_id"),
CONSTRAINT "ept_fk"
FOREIGN KEY ("ept")
REFERENCES "ept" ("id")
INITIALLY DEFERRED)
PARTITION BY RANGE("timestamp");
To summarize, I would like to add the "PARTITION BY" during the schema
generation step because PostgreSQL does not support altering an existing
table into a partitioned one.
Any suggestions?
Best,
Attilio
Il giorno lun 3 mag 2021 alle ore 13:04 Boris Kolpackov <
boris at codesynthesis.com> ha scritto:
> Attilio Priolo <attilio.priolo at gmail.com> writes:
>
> > I was able to use it by manually modifying the SQL schema creation file
> > produced by ODB command line tool.
> > However, I would like to instruct ODB to add this partitioning clause on
> my
> > behalf (e.g. using a pragma).
>
> Can you show/describe what kind of changes you need in the generated
> schema?
>
More information about the odb-users
mailing list