.. versionadded:: 2.0.26
+* ``WITH``:
+
+ Table("some_table", metadata, ..., postgresql_with={"fillfactor": 100})
+
+ Set various storage options on the table
+
* ``WITH OIDS``::
Table("some_table", metadata, ..., postgresql_with_oids=True)
+ Automatically add object identifiers to table rows. Legacy feature, removed
+ in postgresql 12.
+
* ``WITHOUT OIDS``::
Table("some_table", metadata, ..., postgresql_with_oids=False)
if pg_opts["using"]:
table_opts.append("\n USING %s" % pg_opts["using"])
+ if pg_opts["with"]:
+ storage_params = (
+ "%s = %s" % (k, v) for (k, v) in pg_opts["with"].items()
+ )
+ table_opts.append(" WITH (%s)" % ", ".join(storage_params))
+
if pg_opts["with_oids"] is True:
table_opts.append("\n WITH OIDS")
elif pg_opts["with_oids"] is False:
"tablespace": None,
"partition_by": None,
"with_oids": None,
+ "with": None,
"on_commit": None,
"inherits": None,
"using": None,
"CREATE TABLE anothertable (id INTEGER) WITHOUT OIDS",
)
+ def test_create_table_with_storage_parameters(self):
+ m = MetaData()
+
+ tbl = Table("atable1", m, postgresql_with={"fillfactor": 100})
+
+ self.assert_compile(
+ schema.CreateTable(tbl),
+ "CREATE TABLE atable1 () " "WITH (fillfactor = 100)",
+ )
+
+ tbl2 = Table(
+ "atable2",
+ m,
+ postgresql_with={"toast.autovacuum_insert_scale_factor": 1.25},
+ )
+
+ self.assert_compile(
+ schema.CreateTable(tbl2),
+ "CREATE TABLE atable2 () "
+ "WITH (toast.autovacuum_insert_scale_factor = 1.25)",
+ )
+
+ tbl3 = Table(
+ "atable3",
+ m,
+ postgresql_with={
+ "user_catalog_table": False,
+ "parallel_workers": 15,
+ },
+ )
+
+ self.assert_compile(
+ schema.CreateTable(tbl3),
+ "CREATE TABLE atable3 () "
+ "WITH (user_catalog_table = False, parallel_workers = 15)",
+ )
+
def test_create_table_with_oncommit_option(self):
m = MetaData()
tbl = Table(