Apocaleone
Apocaleone

Reputation: 77

How to Delete all the databases in CockroachDB?

I am trying to figure out how to delete all the databases in the CockroachDB using commands, without needing to delete them one by one. If that is not an option, can you point out the directory where all the information of the databases are stored by cockroachDB so that I can manually delete them and be done with it?

Upvotes: 3

Views: 1531

Answers (1)

Marc
Marc

Reputation: 21035

You can't drop all databases at once, they have to be dropped one by one. See the drop database statement.

If you are within a program, you can first fetch the list of databases (SHOW DATABASES, or SELECT datname FROM pg_database), just be sure not to try to drop crdb_internal, information_schema, pg_catalog, or system as they cannot be dropped.

If you want to wipe the cockroach cluster itself, you can kill all nodes and rm -rf <data directory> on each node. The data directory is whatever path you specified in the --store flag (${PWD}/cockroach-data by default).

Upvotes: 4

Related Questions