Over the last couple weeks, you might have noticed a new tab on the cluster view of CockroachDB Cloud! We just released an open preview of our Browser SQL Shell, which allows writing queries on your database within seconds of cluster creation.
While I’m not going to say all SQL should be executed from the browser, working with your database should have as little friction as possible. Iterating on schemas, testing syntax, and executing queries shouldn’t require generating a user and saving a password when you’re getting started. I’m sure we’ve all had stacks of notes storing way too many autogenerated strings for our database credentials.
With CockroachDB Cloud, you can create a multi-region serverless database in less than 30 seconds. Writing SQL queries should feel just as fast, and take advantage of the flexibility a web client has to make the experience better.
Internally, it’s been nice to use it during schema development and validating data in clusters. These little bits of time add up! A shell helps us refocus on the parts of building an app.
The SQL shell isn’t the first experience we’ve released with Syntax highlighting and SQL execution from the browser. Last year, we released our MOLT Schema Conversion Tool (SCT), which helps you iterate on DB schemas while converting it to CockroachDB. The SCT presents each statement with syntax highlighting to help reading table structures.
Our code inputs use Codemirror 6 under the hood, with a custom theme to add a little color to the text. Codemirror 6 hit a sweet spot with performance, bundle size, plugin support, with a lot of active support some great developers. Replit did a fairly large migration over the last 2 years and did an awesome deep dive into the benefits it brings. With this, it’ll be a lot easier to add things like VIM keybindings and helpful cursor interactions down the line!
Codemirror also has great autocomplete support. When you open the shell, we make a query to pull your table schemas and column names to make writing queries a bit quicker. Just navigate the options and click enter to speed up the typing.
The Browser SQL shell has some handy features to help database operations that build on the normal terminal experience. After trying a few variations we felt pretty inspired by Jupyter notebooks and terminals like Warp, which provide persistent queries that can be run in a long running view.
While working across your DB, you can copy the query to share, navigate the history, export to CSVs, and view column types. Query results are rendered in tables to improve readability, and enables local sorting for quickly scanning through your data. Error formats will also reflect what you’d see with our terminal experience to reduce context switching between the two. Feel free to also use ??
syntax for hints when writing your queries.
We’ll be iterating on the shell a fair bit over the next few months. If you have anything you’d like to see, feel free to share it with the feedback button on the page!
What access level do I need?
Why don’t I see the SQL Shell in the console?
Where do I find it?
Is the SQL Shell general availability?
As a developer, you are often faced with the question: why is my application slow? You may have already identified the …
Read moreI periodically need to make changes to tables. Adding columns is very simple with the ALTER TABLE command… But my tables …
Read moreThis post was originally published in 2018 by former CockroachDB engineer Matt Jibson, who owns goats and makes his own …
Read more