2
votes

How can I find out which tables I have in CockroachDB? I tried looking for my schema and couldn't find that, so I'm not sure how to find out which tables I've already created or what their columns are.

1

1 Answers

2
votes

First, you'll need to find your databases (which are CockroachDB's equivalent to PostgreSQL's schemas) using either:

  • MySQL-style SHOW DATABASES statement
  • PostgreSQL-style by querying information_schema.schemata. For example:

    SELECT schema_name FROM information_schema.schemata;

Once you have the database name, you can find the tables using either:

  • MySQL-style SHOW TABLES statement
  • PostgreSQL-style by querying information_schema.tables. For example:

    SELECT table_name FROM information_schema.tables WHERE table_schema = '[database to check]';

Once you find the tables, you can get more information about them using SHOW COLUMNS FROM [table] or the information_schema database.