Is there a simple command that would let me drop all of the tables in a database? I have users/grants set, so I don’t want to drop the database itself, just the tables within it.
CockroachDB doesn't natively support dropping all tables without dropping the database containing them, but you can by running:
cockroach sql --format=csv -e 'SHOW TABLES FROM databasename' \
| tail -n +3 \
| xargs -n1 printf 'DROP TABLE databasename."%s";\n' \
| cockroach sql
If you don't mind also dropping the database, you could just run DROP DATABASE databasename CASCADE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With