Jump directly to main content

SQL Cheatsheet



SQL is a great, simple to use language to manipulate data within a database. This cheatsheet is aimed at basic SQL for MySQL/MariaDB.

Access on the command line

mysql -u  -p

When prompted enter your password

Database manipulation

Show databases

SHOW databases;

Create new databases

CREATE DATABASE IF NOT EXISTS ;

Enter into a database

USE DATABASE ;

or just

USE ;

Table manipulation

Once you've got a database selected, you can play with tables

Create

Read

Update

Delete

Data manipulation

Most of your SQL life will be CRUDing (Create, Read, Update, Delete) data. So I'll cover the basics here

Create

Read

Update

Delete

Create additional users