setup
CREATE TABLE defaultdb.customers (id INT PRIMARY KEY, email STRING UNIQUE);
CREATE TABLE IF NOT EXISTS defaultdb.orders (
    id INT PRIMARY KEY,
    customer INT UNIQUE NOT NULL REFERENCES customers (id),
    orderTotal DECIMAL(9,2),
    INDEX (customer)
  );
CREATE SEQUENCE defaultdb.SQ2;
CREATE TYPE defaultdb.typ AS ENUM('a');
CREATE TABLE defaultdb.shipments (
    tracking_number UUID DEFAULT gen_random_uuid() PRIMARY KEY,
    carrier STRING,
    status STRING,
    customer_id INT,
    randcol INT DEFAULT nextval('defaultdb.sq2'),
    val defaultdb.TYP AS ('a'::defaultdb.typ) STORED,
    CONSTRAINT fk_customers FOREIGN KEY (customer_id) REFERENCES customers(id),
    CONSTRAINT fk_orders FOREIGN KEY (customer_id) REFERENCES orders(customer)
  );
CREATE SEQUENCE defaultdb.SQ1 OWNED BY defaultdb.shipments.carrier;
CREATE VIEW v1 as (select customer_id, carrier from defaultdb.shipments);
COMMENT ON TABLE defaultdb.shipments IS 'shipment is important';
COMMENT ON COLUMN defaultdb.shipments.tracking_number IS 'tracking_number is good';
COMMENT ON INDEX defaultdb.shipments@shipments_pkey IS 'pkey is good';
COMMENT ON CONSTRAINT fk_customers ON defaultdb.shipments IS 'customer is important';
----

build
DROP TABLE defaultdb.shipments CASCADE;
----
- [[Namespace:{DescID: 109, Name: shipments, ReferencedDescID: 100}, ABSENT], PUBLIC]
  {databaseId: 100, descriptorId: 109, name: shipments, schemaId: 101}
- [[Owner:{DescID: 109}, ABSENT], PUBLIC]
  {descriptorId: 109, owner: root}
- [[UserPrivileges:{DescID: 109, Name: admin}, ABSENT], PUBLIC]
  {descriptorId: 109, privileges: "2", userName: admin, withGrantOption: "2"}
- [[UserPrivileges:{DescID: 109, Name: root}, ABSENT], PUBLIC]
  {descriptorId: 109, privileges: "2", userName: root, withGrantOption: "2"}
- [[Table:{DescID: 109}, ABSENT], PUBLIC]
  {tableId: 109}
- [[SchemaChild:{DescID: 109, ReferencedDescID: 101}, ABSENT], PUBLIC]
  {childObjectId: 109, schemaId: 101}
- [[TableComment:{DescID: 109, Comment: shipment is important}, ABSENT], PUBLIC]
  {comment: shipment is important, tableId: 109}
- [[ColumnFamily:{DescID: 109, Name: primary, ColumnFamilyID: 0}, ABSENT], PUBLIC]
  {name: primary, tableId: 109}
- [[Column:{DescID: 109, ColumnID: 1}, ABSENT], PUBLIC]
  {columnId: 1, tableId: 109}
- [[ColumnName:{DescID: 109, Name: tracking_number, ColumnID: 1}, ABSENT], PUBLIC]
  {columnId: 1, name: tracking_number, tableId: 109}
- [[ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 1, TypeName: UUID}, ABSENT], PUBLIC]
  {columnId: 1, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, tableId: 109, type: {family: UuidFamily, oid: 2950}, typeName: UUID}
- [[ColumnNotNull:{DescID: 109, ColumnID: 1, IndexID: 0}, ABSENT], PUBLIC]
  {columnId: 1, tableId: 109}
- [[ColumnDefaultExpression:{DescID: 109, ColumnID: 1, Expr: gen_random_uuid()}, ABSENT], PUBLIC]
  {columnId: 1, expr: gen_random_uuid(), tableId: 109}
- [[ColumnComment:{DescID: 109, ColumnID: 1, Comment: tracking_number is good}, ABSENT], PUBLIC]
  {columnId: 1, comment: tracking_number is good, pgAttributeNum: 1, tableId: 109}
- [[Column:{DescID: 109, ColumnID: 2}, ABSENT], PUBLIC]
  {columnId: 2, tableId: 109}
- [[ColumnName:{DescID: 109, Name: carrier, ColumnID: 2}, ABSENT], PUBLIC]
  {columnId: 2, name: carrier, tableId: 109}
- [[ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 2, TypeName: STRING}, ABSENT], PUBLIC]
  {columnId: 2, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 109, type: {family: StringFamily, oid: 25}, typeName: STRING}
- [[SequenceOwner:{DescID: 109, ColumnID: 2, ReferencedDescID: 110}, ABSENT], PUBLIC]
  {columnId: 2, sequenceId: 110, tableId: 109}
- [[Column:{DescID: 109, ColumnID: 3}, ABSENT], PUBLIC]
  {columnId: 3, tableId: 109}
- [[ColumnName:{DescID: 109, Name: status, ColumnID: 3}, ABSENT], PUBLIC]
  {columnId: 3, name: status, tableId: 109}
- [[ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 3, TypeName: STRING}, ABSENT], PUBLIC]
  {columnId: 3, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 109, type: {family: StringFamily, oid: 25}, typeName: STRING}
- [[Column:{DescID: 109, ColumnID: 4}, ABSENT], PUBLIC]
  {columnId: 4, tableId: 109}
- [[ColumnName:{DescID: 109, Name: customer_id, ColumnID: 4}, ABSENT], PUBLIC]
  {columnId: 4, name: customer_id, tableId: 109}
- [[ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4, TypeName: INT8}, ABSENT], PUBLIC]
  {columnId: 4, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 109, type: {family: IntFamily, oid: 20, width: 64}, typeName: INT8}
- [[Column:{DescID: 109, ColumnID: 5}, ABSENT], PUBLIC]
  {columnId: 5, tableId: 109}
- [[ColumnName:{DescID: 109, Name: randcol, ColumnID: 5}, ABSENT], PUBLIC]
  {columnId: 5, name: randcol, tableId: 109}
- [[ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 5, TypeName: INT8}, ABSENT], PUBLIC]
  {columnId: 5, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 109, type: {family: IntFamily, oid: 20, width: 64}, typeName: INT8}
- [[ColumnDefaultExpression:{DescID: 109, ColumnID: 5, ReferencedSequenceIDs: [106], Expr: nextval(106:::REGCLASS)}, ABSENT], PUBLIC]
  {columnId: 5, expr: 'nextval(106:::REGCLASS)', tableId: 109, usesSequenceIds: [106]}
- [[Column:{DescID: 109, ColumnID: 6}, ABSENT], PUBLIC]
  {columnId: 6, tableId: 109}
- [[ColumnName:{DescID: 109, Name: val, ColumnID: 6}, ABSENT], PUBLIC]
  {columnId: 6, name: val, tableId: 109}
- [[ColumnComputeExpression:{DescID: 109, ReferencedTypeIDs: [107 108], ColumnID: 6, Usage: REGULAR}, ABSENT], PUBLIC]
  {columnId: 6, expr: 'x''80'':::@100107', tableId: 109, usesTypeIds: [107, 108]}
- [[ColumnType:{DescID: 109, ReferencedTypeIDs: [107 108], ColumnFamilyID: 0, ColumnID: 6, TypeName: public.typ}, ABSENT], PUBLIC]
  {closedTypeIds: [107, 108], columnId: 6, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 109, type: {family: EnumFamily, oid: 100107, udtMetadata: {arrayTypeOid: 100108}}, typeName: public.typ}
- [[Column:{DescID: 109, ColumnID: 4294967295}, ABSENT], PUBLIC]
  {columnId: 4.294967295e+09, isHidden: true, isSystemColumn: true, tableId: 109}
- [[ColumnName:{DescID: 109, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT], PUBLIC]
  {columnId: 4.294967295e+09, name: crdb_internal_mvcc_timestamp, tableId: 109}
- [[ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4294967295, TypeName: DECIMAL}, ABSENT], PUBLIC]
  {columnId: 4.294967295e+09, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 109, type: {family: DecimalFamily, oid: 1700}, typeName: DECIMAL}
- [[Column:{DescID: 109, ColumnID: 4294967294}, ABSENT], PUBLIC]
  {columnId: 4.294967294e+09, isHidden: true, isSystemColumn: true, tableId: 109}
- [[ColumnName:{DescID: 109, Name: tableoid, ColumnID: 4294967294}, ABSENT], PUBLIC]
  {columnId: 4.294967294e+09, name: tableoid, tableId: 109}
- [[ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4294967294, TypeName: OID}, ABSENT], PUBLIC]
  {columnId: 4.294967294e+09, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 109, type: {family: OidFamily, oid: 26}, typeName: OID}
- [[Column:{DescID: 109, ColumnID: 4294967293}, ABSENT], PUBLIC]
  {columnId: 4.294967293e+09, isHidden: true, isSystemColumn: true, tableId: 109}
- [[ColumnName:{DescID: 109, Name: crdb_internal_origin_id, ColumnID: 4294967293}, ABSENT], PUBLIC]
  {columnId: 4.294967293e+09, name: crdb_internal_origin_id, tableId: 109}
- [[ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4294967293, TypeName: INT4}, ABSENT], PUBLIC]
  {columnId: 4.294967293e+09, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 109, type: {family: IntFamily, oid: 23, width: 32}, typeName: INT4}
- [[Column:{DescID: 109, ColumnID: 4294967292}, ABSENT], PUBLIC]
  {columnId: 4.294967292e+09, isHidden: true, isSystemColumn: true, tableId: 109}
- [[ColumnName:{DescID: 109, Name: crdb_internal_origin_timestamp, ColumnID: 4294967292}, ABSENT], PUBLIC]
  {columnId: 4.294967292e+09, name: crdb_internal_origin_timestamp, tableId: 109}
- [[ColumnType:{DescID: 109, ColumnFamilyID: 0, ColumnID: 4294967292, TypeName: DECIMAL}, ABSENT], PUBLIC]
  {columnId: 4.294967292e+09, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 109, type: {family: DecimalFamily, oid: 1700}, typeName: DECIMAL}
- [[IndexColumn:{DescID: 109, ColumnID: 1, IndexID: 1}, ABSENT], PUBLIC]
  {columnId: 1, indexId: 1, tableId: 109}
- [[IndexColumn:{DescID: 109, ColumnID: 2, IndexID: 1}, ABSENT], PUBLIC]
  {columnId: 2, indexId: 1, kind: STORED, tableId: 109}
- [[IndexColumn:{DescID: 109, ColumnID: 3, IndexID: 1}, ABSENT], PUBLIC]
  {columnId: 3, indexId: 1, kind: STORED, ordinalInKind: 1, tableId: 109}
- [[IndexColumn:{DescID: 109, ColumnID: 4, IndexID: 1}, ABSENT], PUBLIC]
  {columnId: 4, indexId: 1, kind: STORED, ordinalInKind: 2, tableId: 109}
- [[IndexColumn:{DescID: 109, ColumnID: 5, IndexID: 1}, ABSENT], PUBLIC]
  {columnId: 5, indexId: 1, kind: STORED, ordinalInKind: 3, tableId: 109}
- [[IndexColumn:{DescID: 109, ColumnID: 6, IndexID: 1}, ABSENT], PUBLIC]
  {columnId: 6, indexId: 1, kind: STORED, ordinalInKind: 4, tableId: 109}
- [[PrimaryIndex:{DescID: 109, IndexID: 1, ConstraintID: 1}, ABSENT], PUBLIC]
  {constraintId: 1, indexId: 1, isUnique: true, tableId: 109}
- [[IndexName:{DescID: 109, Name: shipments_pkey, IndexID: 1}, ABSENT], PUBLIC]
  {indexId: 1, name: shipments_pkey, tableId: 109}
- [[IndexComment:{DescID: 109, IndexID: 1, Comment: pkey is good}, ABSENT], PUBLIC]
  {comment: pkey is good, indexId: 1, tableId: 109}
- [[IndexData:{DescID: 109, IndexID: 1}, ABSENT], PUBLIC]
  {indexId: 1, tableId: 109}
- [[ForeignKeyConstraint:{DescID: 109, IndexID: 0, ConstraintID: 2, ReferencedColumnIDs: [1], ReferencedDescID: 104}, ABSENT], PUBLIC]
  {columnIds: [4], constraintId: 2, referencedColumnIds: [1], referencedTableId: 104, tableId: 109}
- [[ConstraintWithoutIndexName:{DescID: 109, Name: fk_customers, ConstraintID: 2}, ABSENT], PUBLIC]
  {constraintId: 2, name: fk_customers, tableId: 109}
- [[ConstraintComment:{DescID: 109, ConstraintID: 2, Comment: customer is important}, ABSENT], PUBLIC]
  {comment: customer is important, constraintId: 2, tableId: 109}
- [[ForeignKeyConstraint:{DescID: 109, IndexID: 0, ConstraintID: 3, ReferencedColumnIDs: [2], ReferencedDescID: 105}, ABSENT], PUBLIC]
  {columnIds: [4], constraintId: 3, referencedColumnIds: [2], referencedTableId: 105, tableId: 109}
- [[ConstraintWithoutIndexName:{DescID: 109, Name: fk_orders, ConstraintID: 3}, ABSENT], PUBLIC]
  {constraintId: 3, name: fk_orders, tableId: 109}
- [[TableData:{DescID: 109, ReferencedDescID: 100}, ABSENT], PUBLIC]
  {databaseId: 100, tableId: 109}
- [[Namespace:{DescID: 110, Name: sq1, ReferencedDescID: 100}, ABSENT], PUBLIC]
  {databaseId: 100, descriptorId: 110, name: sq1, schemaId: 101}
- [[Owner:{DescID: 110}, ABSENT], PUBLIC]
  {descriptorId: 110, owner: root}
- [[UserPrivileges:{DescID: 110, Name: admin}, ABSENT], PUBLIC]
  {descriptorId: 110, privileges: "2", userName: admin, withGrantOption: "2"}
- [[UserPrivileges:{DescID: 110, Name: root}, ABSENT], PUBLIC]
  {descriptorId: 110, privileges: "2", userName: root, withGrantOption: "2"}
- [[Sequence:{DescID: 110}, ABSENT], PUBLIC]
  {sequenceId: 110}
- [[SchemaChild:{DescID: 110, ReferencedDescID: 101}, ABSENT], PUBLIC]
  {childObjectId: 110, schemaId: 101}
- [[TableData:{DescID: 110, ReferencedDescID: 100}, ABSENT], PUBLIC]
  {databaseId: 100, tableId: 110}
- [[Namespace:{DescID: 111, Name: v1, ReferencedDescID: 100}, ABSENT], PUBLIC]
  {databaseId: 100, descriptorId: 111, name: v1, schemaId: 101}
- [[Owner:{DescID: 111}, ABSENT], PUBLIC]
  {descriptorId: 111, owner: root}
- [[UserPrivileges:{DescID: 111, Name: admin}, ABSENT], PUBLIC]
  {descriptorId: 111, privileges: "2", userName: admin, withGrantOption: "2"}
- [[UserPrivileges:{DescID: 111, Name: root}, ABSENT], PUBLIC]
  {descriptorId: 111, privileges: "2", userName: root, withGrantOption: "2"}
- [[View:{DescID: 111}, ABSENT], PUBLIC]
  {forwardReferences: [{columnIds: [2, 4], toId: 109}], usesRelationIds: [109], viewId: 111}
- [[SchemaChild:{DescID: 111, ReferencedDescID: 101}, ABSENT], PUBLIC]
  {childObjectId: 111, schemaId: 101}
- [[Column:{DescID: 111, ColumnID: 1}, ABSENT], PUBLIC]
  {columnId: 1, tableId: 111}
- [[ColumnName:{DescID: 111, Name: customer_id, ColumnID: 1}, ABSENT], PUBLIC]
  {columnId: 1, name: customer_id, tableId: 111}
- [[ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 1, TypeName: INT8}, ABSENT], PUBLIC]
  {columnId: 1, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 111, type: {family: IntFamily, oid: 20, width: 64}, typeName: INT8}
- [[Column:{DescID: 111, ColumnID: 2}, ABSENT], PUBLIC]
  {columnId: 2, tableId: 111}
- [[ColumnName:{DescID: 111, Name: carrier, ColumnID: 2}, ABSENT], PUBLIC]
  {columnId: 2, name: carrier, tableId: 111}
- [[ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 2, TypeName: STRING}, ABSENT], PUBLIC]
  {columnId: 2, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 111, type: {family: StringFamily, oid: 25}, typeName: STRING}
- [[Column:{DescID: 111, ColumnID: 4294967295}, ABSENT], PUBLIC]
  {columnId: 4.294967295e+09, isHidden: true, isSystemColumn: true, tableId: 111}
- [[ColumnName:{DescID: 111, Name: crdb_internal_mvcc_timestamp, ColumnID: 4294967295}, ABSENT], PUBLIC]
  {columnId: 4.294967295e+09, name: crdb_internal_mvcc_timestamp, tableId: 111}
- [[ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 4294967295, TypeName: DECIMAL}, ABSENT], PUBLIC]
  {columnId: 4.294967295e+09, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 111, type: {family: DecimalFamily, oid: 1700}, typeName: DECIMAL}
- [[Column:{DescID: 111, ColumnID: 4294967294}, ABSENT], PUBLIC]
  {columnId: 4.294967294e+09, isHidden: true, isSystemColumn: true, tableId: 111}
- [[ColumnName:{DescID: 111, Name: tableoid, ColumnID: 4294967294}, ABSENT], PUBLIC]
  {columnId: 4.294967294e+09, name: tableoid, tableId: 111}
- [[ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 4294967294, TypeName: OID}, ABSENT], PUBLIC]
  {columnId: 4.294967294e+09, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 111, type: {family: OidFamily, oid: 26}, typeName: OID}
- [[Column:{DescID: 111, ColumnID: 4294967293}, ABSENT], PUBLIC]
  {columnId: 4.294967293e+09, isHidden: true, isSystemColumn: true, tableId: 111}
- [[ColumnName:{DescID: 111, Name: crdb_internal_origin_id, ColumnID: 4294967293}, ABSENT], PUBLIC]
  {columnId: 4.294967293e+09, name: crdb_internal_origin_id, tableId: 111}
- [[ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 4294967293, TypeName: INT4}, ABSENT], PUBLIC]
  {columnId: 4.294967293e+09, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 111, type: {family: IntFamily, oid: 23, width: 32}, typeName: INT4}
- [[Column:{DescID: 111, ColumnID: 4294967292}, ABSENT], PUBLIC]
  {columnId: 4.294967292e+09, isHidden: true, isSystemColumn: true, tableId: 111}
- [[ColumnName:{DescID: 111, Name: crdb_internal_origin_timestamp, ColumnID: 4294967292}, ABSENT], PUBLIC]
  {columnId: 4.294967292e+09, name: crdb_internal_origin_timestamp, tableId: 111}
- [[ColumnType:{DescID: 111, ColumnFamilyID: 0, ColumnID: 4294967292, TypeName: DECIMAL}, ABSENT], PUBLIC]
  {columnId: 4.294967292e+09, elementCreationMetadata: {in231OrLater: true, in243OrLater: true}, isNullable: true, tableId: 111, type: {family: DecimalFamily, oid: 1700}, typeName: DECIMAL}
