SQL Cheatsheet

sql cheatsheet - photo of library to represent a database

Here is a quick SQL cheatsheet for the basic CRUD database functions.


The SELECT statement reads from the database and returns a list of information that matches your query. The first statement will return all the information in a table, if there are a lot of columns this may be difficult to read, and will also slow down your program if you are retrieving a lot of irrelevant information. To narrow down your search, try naming only the columns you really need.

SELECT * FROM tablename;
SELECT columname, columnnme FROM tablename;


The INSERT statement allows you to add new rows to a table. Some columns may have default values or allow null values. Otherwise you will need to specify a value for each column in the table when you add a new row.

INSERT INTO tablename (column1, column2) VALUES (value1, value2);


The UPDATE statement allows you to update existing information in a table. You will need to be careful to specify which row(s) to update or you may accidentally overwrite things you wanted to save.

UPDATE tablename SET column1=value1, column2=value2 WHERE column3=value3;


The DELETE statement allows you to delete rows from a table. Like updating, you need to be careful to specify which rows, or else you may delete your entire table!

DELETE FROM tablename WHERE columnname=value;