Referencia · §8.33

The schema as SQL

definitions, §M14.16 M1

Ez az oldal a nucleus saját dokumentációjából készül, ezért angol nyelvű.

nc_catalog.definitions (position, kind, name, table_name, definition) is every schema object as the statement that makes it, written by the engine from its catalog records (definitions::all) — not text kept from when the object was made: a table altered many times is one CREATE TABLE of what it is now. In position order the statements replay on an empty database: models (CREATE MODEL … WITH (…), the provider’s options, prefixes and limits), enum types, orderings, operators and casts taught to types; tables — ordinary and partitioned ones by name (columns with their types, NOT NULL, defaults, GENERATED ALWAYS AS … STORED, GENERATED BY EMBEDDING … USING model; the primary key, unique constraints and checks by name; PARTITION BY, WITH (storage = …)), then partitions (PARTITION OF … FOR VALUES …), memory stores (CREATE MEMORY STORE … WITH (merge, analyzer)), chunk tables (CHUNKS OF) and collections (CREATE COLLECTION … WITH (schema, storage, engine)), and the columns and constraints added to those since; indexes (method, expressions, orderings, operator classes, options — the method’s as it filled them in), statistics objects; foreign keys after every table, so a cycle needs no order; comments; each table’s storage (SET STORAGE row, column, a storage policy), expiry, subjects and row security; policies. An index on a partitioned table is its partitions’ too, and a partition’s columns, keys and indexes are its parent’s: neither is written twice. Names are quoted only where they must be (upper case, a reserved word, other characters); option values bare when they are a number or a word.

Left out: roles, grants and ownership (who may, not what is, as pg_dump --no-owner --no-acl), secrets (their values are never shown — a model that names one needs it made first), access rules, tokens, database settings, and data (BACKUP TO, §8.30).

nucleus dump --schema <dir | :memory: | -h host …> prints them, one statement a line. The law, tested on a schema with every kind of object and on what each of the test kit’s scripts leaves: a schema’s definitions, run on an empty database, give the same definitions (crates/sql/tests/definitions.rs).