Skip to content

MySQL Workbench Tutorial: SQL Database Creation and Management

Getting Started with MySQL Workbench

SQL (Structured Query Language) is used to create, retrieve, update, and delete data from a database. Think of a relational database as a collection of tables (like Excel spreadsheets) that can be linked together using keys. For a broader introduction to these concepts, see Introduction to Database Management Systems: Basics and Key Concepts.

Downloading MySQL

For Windows:

  • Visit mysql.com → Downloads → MySQL Community Downloads
  • Select MySQL Installer for Windows
  • Choose Custom setup, add MySQL Server and MySQL Workbench
  • Set a root password during installation
  • Launch MySQL Workbench after setup

For Mac OS:

  • Download MySQL Server DMG archive and MySQL Workbench separately from mysql.com
  • Install MySQL Server first, set a password
  • Enable MySQL server in System Preferences → MySQL
  • Drag MySQL Workbench to Applications folder
  • Connect using local instance at 127.0.0.1:3306

Working with Databases

A database is like a folder that contains tables. Here's how to manage them. If you're new to databases, Aprende MySQL: Introducción y Primeros Pasos para Crear Bases de Datos offers a great introduction in Spanish.

Creating and Using a Database

CREATE DATABASE mydb;
USE mydb;

Altering a Database

-- Set to read-only
ALTER DATABASE mydb READ ONLY = 1;

-- Remove read-only
ALTER DATABASE mydb READ ONLY = 0;

Dropping a Database

DROP DATABASE mydb;

Creating and Managing Tables

Tables consist of rows and columns. Each column needs a data type.

Create a Table

CREATE TABLE employees (
    employee_id INT,
    first_name VARCHAR(50),
    last_name VARCHAR(50),
    hourly_pay DECIMAL(5,2),
    hire_date DATE
);

View Table Structure

SELECT * FROM employees;

Rename a Table

RENAME TABLE employees TO workers;

Drop a Table

DROP TABLE employees;

Alter a Table - Add Column

ALTER TABLE employees
ADD phone_number VARCHAR(15);

Alter a Table - Rename Column

ALTER TABLE employees
RENAME COLUMN phone_number TO email;

Alter a Table - Modify Column

ALTER TABLE employees
MODIFY COLUMN email VARCHAR(100);

-- Move column position
ALTER TABLE employees
MODIFY COLUMN email VARCHAR(100) AFTER last_name;

Alter a Table - Drop Column

ALTER TABLE employees
DROP COLUMN email;

Inserting Rows

Insert a Single Row

INSERT INTO employees
VALUES (1, 'Eugene', 'Krabs', 25.50, '2023-01-02');

Insert Multiple Rows

INSERT INTO employees
VALUES
(2, 'Squidward', 'Tentacles', 15.00, '2023-01-03'),
(3, 'SpongeBob', 'SquarePants', 12.50, '2023-01-04'),
(4, 'Patrick', 'Star', 12.50, '2023-01-05'),
(5, 'Sandy', 'Cheeks', 17.25, '2023-01-06');

Insert with Specific Columns

INSERT INTO employees (employee_id, first_name, last_name)
VALUES (6, 'Sheldon', 'Plankton');

For more examples of populating a database, check out How to Create Dummy Data for Bike Store Database in SQL Server.

Querying Data

Select All Data

SELECT * FROM employees;

Select Specific Columns

SELECT first_name, last_name FROM employees;

Using WHERE Clause

-- Find by ID
SELECT * FROM employees WHERE employee_id = 1;

-- Find by name
SELECT * FROM employees WHERE first_name = 'SpongeBob';

-- Comparison operators
SELECT * FROM employees WHERE hourly_pay >= 15;

-- Date comparison
SELECT * FROM employees WHERE hire_date <= '2023-01-03';

-- Not equal
SELECT * FROM employees WHERE employee_id != 1;

-- Check for NULL
SELECT * FROM employees WHERE hire_date IS NULL;
SELECT * FROM employees WHERE hire_date IS NOT NULL;

Updating and Deleting Data

Update a Single Field

UPDATE employees
SET hourly_pay = 10.25
WHERE employee_id = 6;

Update Multiple Fields

UPDATE employees
SET hourly_pay = 10.50, hire_date = '2023-01-07'
WHERE employee_id = 6;

Set a Field to NULL

UPDATE employees
SET hire_date = NULL
WHERE employee_id = 6;

Warning: Omitting the WHERE clause updates ALL rows.

Delete a Row

DELETE FROM employees
WHERE employee_id = 6;

Warning: DELETE FROM employees without WHERE deletes ALL rows.

For a complete journey from beginner to expert in SQL, including more advanced topics like joins and subqueries, visit SQL Complete Tutorial: From Zero to Expert (No Prerequisites). Additionally, Comprehensive SQL Course: From Basics to Advanced Database Design provides a deeper dive into database design principles.

Keep this summary

Save it to LunaNotes and it becomes a real note in your library — editable, searchable, and ready to turn into flashcards or a diagram. Free to start.

Save to LunaNotes

Or summarise for another video.

32K+ people have turned 65K+ videos into notes

“Very useful tool. I'm using it for the last couple weeks and I'm loving it so far. Makes learning on YouTube a great experience.”
Bhai Chrome Web Store review

This summary and transcript were automatically generated using AI with the Free YouTube transcript summary tool by LunaNotes.

Related summaries

SQL Complete Tutorial: From Zero to Expert (No Prerequisites)

SQL Complete Tutorial: From Zero to Expert (No Prerequisites)

This hands-on SQL tutorial transforms complete beginners into SQL experts, covering database fundamentals, SQL installation on Windows/Mac/Linux, and core commands like CREATE, SELECT, INSERT, UPDATE, and DELETE. Learn how to design tables, use constraints, write queries, and understand relational vs. non-relational databases—all with downloadable notes and a companion blog.

Comprehensive SQL Course: From Basics to Advanced Database Design

Comprehensive SQL Course: From Basics to Advanced Database Design

Master SQL with this full beginner-friendly course covering database fundamentals, MySQL installation, table creation, data manipulation, complex querying, joins, triggers, ER diagrams, and converting ER diagrams to schemas. Learn practical examples and advanced techniques to design and manage relational databases effectively.

Complete SQL Interview Prep: 15 Must-Know Queries & Concepts

Complete SQL Interview Prep: 15 Must-Know Queries & Concepts

Master essential SQL interview questions in this comprehensive guide covering 15+ crucial topics, including joins, window functions, aggregations, and data manipulation. Learn to solve common challenges like finding second highest salaries, removing duplicates, and handling NULL values with clear, step-by-step query explanations.

A Comprehensive Guide to PostgreSQL: Basics, Features, and Advanced Concepts

A Comprehensive Guide to PostgreSQL: Basics, Features, and Advanced Concepts

Learn PostgreSQL fundamentals, features, and advanced techniques to enhance your database management skills.

Understanding the ALTER Command in SQL: A Comprehensive Guide

Understanding the ALTER Command in SQL: A Comprehensive Guide

In this video, Varun Singla explains the ALTER command in SQL, a crucial part of Data Definition Language (DDL). He covers its various functionalities, including adding, dropping, modifying, and renaming columns and tables, as well as managing constraints. The video includes practical implementation examples in Oracle, making it easy to understand the command's applications.

Found this summary useful?

Take it with you. One click puts it in your own LunaNotes library.

Save to LunaNotes

Start taking better notes today with LunaNotes