SQL Basics Cheat Sheet with Examples: A Quick Reference Guide

Welcome to your comprehensive SQL basics cheat sheet! Structured Query Language, or SQL, is an essential tool for database management and manipulation. This guide will empower you to interact confidently with databases, creating, updating, and retrieving data with ease. Let's dive right in!

SQL Basics Cheat Sheet for Beginners | Learn SQL Fast 💻
SQL Basics Cheat Sheet for Beginners | Learn SQL Fast 💻

Whether you're a beginner or refreshing your SQL skills, this cheat sheet will provide clear, concise instructions along with practical examples.

SQL Quick Notes Cheat Sheet | SQL Queries, Joins, Functions & Database Commands for Beginners
SQL Quick Notes Cheat Sheet | SQL Queries, Joins, Functions & Database Commands for Beginners

SQL Basics: Database Creation and Data Manipulation

To commence, let's explore how to create a database and manipulate data within it.

SQL Basics Every Beginner Must Learn | Ultimate SQL Cheat Sheet
SQL Basics Every Beginner Must Learn | Ultimate SQL Cheat Sheet

First, we'll create a new database named 'MyDatabase'.

Creating a New Database

Learn SQL Fast 🚀 | Beginner SQL Commands Cheat Sheet for Data Analysts
Learn SQL Fast 🚀 | Beginner SQL Commands Cheat Sheet for Data Analysts

To create a new database, use the following SQL statement:

CREATE DATABASE MyDatabase;

Once the database is created, we can switch to it using the 'USE' command:

SQL Joins Explained with Examples | Complete JOIN Cheat Sheet for Beginners
SQL Joins Explained with Examples | Complete JOIN Cheat Sheet for Beginners

USE MyDatabase;

Creating Tables

Next, let's create a table named 'Users'. For this example, we'll include 'id', 'name', and 'email' columns.

SQL Commands Cheat Sheet: DDL, DML, DCL, TCL & Joins Explained
SQL Commands Cheat Sheet: DDL, DML, DCL, TCL & Joins Explained

The SQL command to create a table is as follows:

CREATE TABLE Users ( id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100) NOT NULL, email VARCHAR(255) UNIQUE NOT NULL );

SQL Basics CHEAT SHEET
SQL Basics CHEAT SHEET
SQL Cheat Sheet
SQL Cheat Sheet
SQL Cheat Sheet for Beginners
SQL Cheat Sheet for Beginners
SQL Cheat Sheet in 60 seconds 👇
SQL Cheat Sheet in 60 seconds 👇
a large poster with different types of food
a large poster with different types of food
SQL Essentials Cheat Sheet | The Only SQL Notes You'll Need for Revision
SQL Essentials Cheat Sheet | The Only SQL Notes You'll Need for Revision
SQL Cheat Sheet for Beginners
SQL Cheat Sheet for Beginners
Oracle SQL Cheat Sheet
Oracle SQL Cheat Sheet
SQL cheat sheet
SQL cheat sheet
SQL Cheat Sheet for Beginners | Essential Commands & Queries
SQL Cheat Sheet for Beginners | Essential Commands & Queries
Complete SQL Cheat Sheet for Beginners | SQL Commands, Joins, Queries & Database Guide
Complete SQL Cheat Sheet for Beginners | SQL Commands, Joins, Queries & Database Guide
SQL Aggregate Functions Cheat Sheet for Beginners
SQL Aggregate Functions Cheat Sheet for Beginners
SQL Cheat Sheet for Beginners | SELECT, JOINS, GROUP BY, Queries & Commands Quick Revision
SQL Cheat Sheet for Beginners | SELECT, JOINS, GROUP BY, Queries & Commands Quick Revision
SQL Cheatsheet In 2026 🚀
SQL Cheatsheet In 2026 🚀
📄 SQL Cheatsheet: Essential Commands and Examples 🛠️ | Programming Valley
📄 SQL Cheatsheet: Essential Commands and Examples 🛠️ | Programming Valley
5 SQL Aggregate Functions You'll Use Every Day
5 SQL Aggregate Functions You'll Use Every Day
SQL Cheat Sheet for Beginners
SQL Cheat Sheet for Beginners
SQL Joins Explained 🚀 | Beginner Data Analyst SQL Guide
SQL Joins Explained 🚀 | Beginner Data Analyst SQL Guide
SQL & Databases Cheat Sheet for Developers
SQL & Databases Cheat Sheet for Developers
7 SQL Projects for Beginners | Build a Real Data Portfolio
7 SQL Projects for Beginners | Build a Real Data Portfolio

SQL Basics: Inserting, Updating, Deleting Data

Now that we've created our database and table, let's see how to insert, update, and delete data.

Inserting Data

To add a new user, use the 'INSERT INTO' command:

INSERT INTO Users (name, email) VALUES ('John Doe', 'john.doe@example.com');

Updating Data

Sometimes, you'll need to update existing data. Here's how to update John Doe's email:

UPDATE Users SET email = 'new.email@example.com' WHERE name = 'John Doe';

Deleting Data

Deleting data is straightforward using the 'DELETE' command. Let's remove John Doe:

DELETE FROM Users WHERE name = 'John Doe';

SQL Basics: Retrieving Data with SELECT

Retrieving data is the most common operation in SQL. Let's fetch all users and their emails.

Basic SELECT Command

Using the 'SELECT' command, we can fetch all columns from the 'Users' table:

SELECT * FROM Users;

SELECT with Conditions

To fetch specific data, add a 'WHERE' clause. Here's how to find users with the name 'Jane':

SELECT * FROM Users WHERE name = 'Jane';

Now that you've mastered these SQL basics, explore and expand your skills with more advanced topics like joins, subqueries, and aggregate functions. Happy coding!

Related Articles

W3 Sql Regex Difference Between Mysql And Sql Server Management Studio Sql Query Parameters Example W3schools Sql Server Declare Sql Server Management Studio W3 W3s Sql Update W3schools Sql On W3 Sql Syntax Sql Set Variable W3schools W3schools Sql Set Operators