ORT-SQL(1) General Commands Manual ORT-SQL(1)

ort-sqlproduce ort SQL schema

ort-sql [config...]

The ort-sql utility accepts ort(5) config files, defaulting to standard input, and produces an SQL schema. The SQL generated is designed for sqlite3(1).

Output always begins with PRAGMA foreign_keys=ON regardless of whether the configuration has any references.

The schema begins of a series of CREATE TABLE SQL commands for each struct object in config. The name of the table inherits from the structure name.

Each field within each struct is mapped into a representative SQL type except the struct, which is a virtual type. The name of the column inherits from the field name.

Furthermore, types may have the following attributes.

If null is not specified, the SQL column is marked as NOT NULL. The default attribute is type-specific.

Reference types may contain the actup and actdel attributes map as follows:

These are assigned as FOREIGN KEY(xxx) REFERENCE yyy(zzz) followed by the update or delete clause, if applicable.

Lastly, any unique statement on the structure is rendered as a unique index. The name of the index is the (sorted) fields in the unique statement, separated by underscores, and prefixed with “unique_strct__” where “strct” is the name of the structure. Thus, an example structure “xyzzy” having unique(foo, bar) would be rendered as:

CREATE UNIQUE INDEX unique_xyzzy__bar_foo ON xyzzy(foo, bar);

The ort-sql utility exits 0 on success, and >0 if an error occurs.

ort-sqldiff(1), sqlite3(1), ort(5)

October 25, 2021 OpenBSD 6.7