Are you tired of remembering different database commands or scouring the internet for a complete source?
Well, you’ve come to the right place! This blog series, The Database Cheatsheet, contains everything you need to know about database commands, covering everything developers and database professionals need to know to use and operate their databases.
First, here is a quick disclaimer: these commands are tailored explicitly for SingleStore. If you plan to use them on other database platforms, be sure to check the documentation to confirm compatibility or required syntax changes. Need a database to get started with? Sign up for a free SingleStore Helios® trial to get up and running in minutes.
SingleStore Database Cheat Sheet
- SingleStore core concepts
- SQL + Kai commands
- Vector operations tips
In this post, we’ll look at common database operations — the essential commands that let you create, select and manage your databases in SingleStore. Whether you’re new to SingleStore or coming from another SQL/NoSQL environment, these instructions will help you get up and running quickly. Remember that while these commands work as-is in SingleStore, you may need to adjust them slightly for other platforms.
1. Show databases
Want to see all of the databases accessible in your current environment? That’s exactly what this command is for. Running this will retrieve a list of all databases accessible within your current SingleStore environment.
SHOW DATABASES;
Once the command is executed, you’ll see a list of database names. Note that if you’ve just started with SingleStore, you might see only system databases or a small set of user databases.
2. Create database
Need to create a database to work with? Running the following command creates a new database in SingleStore. Replace database_name with the name you want for your database (e.g., my_database).
CREATE DATABASE database_name;
After running the command, you’ll have a new, empty database ready to create tables and insert data. You can confirm its creation by rerunning the SHOW DATABASES command.
3. Use database
To utilize a database, you need to ensure that your session uses it. By running the following command, your session’s active database will switch to database_name (your database name).
USE database_name;
After running this command, your SQL session context is now set to the specified database. All subsequent commands (like creating tables, inserting data, and more) will apply to this database unless specified otherwise.
4. Drop database
Need to delete or “drop” a database? By running this command, you will completely delete an existing database specified in the database_name parameter, along with all the tables and data inside it.
DROP DATABASE database_name;
Once the command is completed and the database is dropped, the database no longer appears when the SHOW DATABASES command is executed. You cannot retrieve any data or tables that were in it. Be cautious — this operation is irreversible.
Try SingleStore free
In this blog post, we covered the fundamental database operations you’ll use daily in SingleStore. These commands are the building blocks of managing your data environment, from listing existing databases to creating and selecting a new database — and finally removing a database when it’s no longer needed. Check out our other Database Cheatsheet articles or access the notebook in SingleStore Spaces for easy reference.
Disclaimer
These commands are specifically tailored for SingleStore. If you plan to use them on other SQL platforms, ensure you check the documentation to confirm compatibility or required syntax changes. Need a database to get started with? Sign up for a free SingleStore Helios® trial to get up and running in minutes.