top of page

How to use ChatGPT to explore Database Schema

SchemaCrawler is a relational database exploration tool. It obtains database schema metadata such as tables, stored procedures, foreign keys, triggers and so on, and makes them available for search. The traditional way to use SchemaCrawler has been the command-line or an interactive shell.

SchemaCrawler is now integrated with ChatGPT to provide an interactive way to interrogate your database schema metadata. When you start SchemaCrawler with the “chatgpt” command, you will have an interactive chat shell with ChatGPT, enhanced with information about your database metadata. You can try prompts such as the following ones:

  • "List all schemas"

  • "List all tables"

  • "Describe the Track table"

  • "Show me all the details of a table whose name is something like 'tra'"

  • "What are the indexes on the Track table?"

  • "What are the Track columns?"

  • "What is the Track primary key?"

  • "Show me the triggers on Track"

  • "Find the parents of Track"

  • "What are the dependents of Album?"

To quit the console, you can type something like:

  • "I think I have everything I need" or simply, "done", "exit" or "quit".

To start using this integration, you will need to create your own OpenAI API key. Then download a SQLite database called "chinook-database-2.0.1.sqlite" into your current directory.

Run this command:

docker run \
--mount type=bind,source="${PWD}",target=/home/schcrwlr \
--rm -it \
schemacrawler/schemacrawler \
/opt/schemacrawler/bin/ \
--server=sqlite \
--database=chinook-database-2.0.1.sqlite \
--info-level=standard \
--command=chatgpt \

(If you are using PowerShell on Windows, replace the trailing backslash on each line with a back-tick, and map the current directory differently.) At the prompt, enter some of the commands above.

After you have got this working, use the SchemaCrawler command-line to connect to your own database, and explore it using a natural language interface courtesy of ChatGPT.

108 views0 comments


Rated 0 out of 5 stars.
No ratings yet

Add a rating
Stationary photo

Be the first to know

Subscribe to our newsletter to receive news and updates.

Thanks for submitting!

Follow us
bottom of page