# dbtoyaml - Database to YAML `dbtoyaml` — extract the schema of a PostgreSQL database in YAML format ## Synopsis ``` dbtoyaml [option...] dbname ``` ## Description **dbtoyaml** is a utility for extracting the schema of a PostgreSQL database to a YAML formatted specification. By default, the specification is output as a single output stream, which can be redirected or explicitly sent to a file. A sample of the output format is as follows: ```yaml schema public: table film: columns: - id: type: integer not_null: true - title: type: character varying(32) primary_key: film_pkey: columns: - id ``` See {doc}`yaml-format` for the full YAML format reference. ## Positional arguments `dbname` : The name of the database whose schema is to be extracted. ## Options **dbtoyaml** accepts the following arguments (in addition to the {doc}`common-options`): `-o `, `--output ` : Send output to the specified *file* name. `-n `, `--schema ` : Extract only a SQL schema (namespace) matching *schema*. By default, all SQL schemas are extracted. Multiple schemas can be extracted by using multiple `-n` options. Note that normally all objects that belong to the SQL schema are extracted as well, unless otherwise excluded. `-O`, `--no-owner` : Exclude object ownership information from the output. `-t `, `--table
` : Extract only a table matching *table*. By default, all tables are extracted. Multiple tables can be extracted by using multiple `-t` switches. ## Examples To extract a database called `testdb` into a file: ``` dbtoyaml testdb > testdb.yaml ``` To extract only the PostgreSQL schema named `public`: ``` dbtoyaml --schema=public testdb > testdb.yaml ``` To extract the tables named `film` and `genre` to a named file: ``` dbtoyaml -t film -t genre testdb -o testdb.yaml ```