The cockroach gen command can generate command-line interface (CLI) utilities (man pages and abash autocompletion script), as well as example SQL data suitable to populate test databases.

Subcommands

Subcommand Usage
man Generate man pages for CockroachDB.
autocomplete Generate bash autocompletion script for CockroachDB.
example-data Generate example SQL code.

Synopsis

# Generate man pages:
$ cockroach gen man 

# Generate bash autocompletion script:
$ cockroach gen autocomplete

# Generate example SQL data:
$ cockroach gen example-data | cockroach sql

# View help:
$ cockroach gen --help
$ cockroach gen man --help
$ cockroach gen autocomplete --help
$ cockroach gen example-data --help

Flags

The gen subcommands only support logging flags.

Examples

Generate man Pages

# Generate man pages:
$ cockroach gen man

# Move the man pages to the man directory:
$ sudo mv man/man1/* /usr/share/man/man1

# Access man pages:
$ man cockroach

Generate bash Autocompletion Script

# Generate bash autocompletion script:
$ cockroach gen autocomplete

# Add the script to your .bashrc and .bash_profle:
$ printf "\n\n#cockroach bash autocomplete\nsource '<path to>cockroach.bash'" >> ~/.bashrc
$ printf "\n\n#cockroach bash autocomplete\nsource '<path to>cockroach.bash'" >> ~/.bash_profile

You can now use tab to autocomplete cockroach commands.

Generate Example Data

To test out CockroachDB, you can generate an example database, startrek, that contains 2 tables, episodes and quotes.

# Generate example SQL data:
$ cockroach gen example-data | cockroach sql

# Launch the built-in SQL client to view it:
$ cockroach sql
> SHOW TABLES FROM startrek;
+----------+
|  Table   |
+----------+
| episodes |
| quotes   |
+----------+
You can find example databases by using cockroach gen example-data --help.

See Also

Other Cockroach Commands



Yes No