MasterPHP.in
MySQL Tutorial

First SQL Commands


Introduction

Now that you have MySQL installed, it’s time to start working with it.

In this lesson, you will write your first SQL commands and understand how to interact with a database.


What is SQL?

SQL stands for Structured Query Language.

It is the language used to communicate with databases. With SQL, you can create databases, store data, retrieve it, and modify it.

Every action you perform in MySQL is done using SQL commands.


Creating Your First Database

Let’s start by creating a database.

CREATE DATABASE myapp;

This command creates a new database named myapp.


Viewing Available Databases

To see all the databases on your system, use:

SHOW DATABASES;

This will display a list of all existing databases.


Selecting a Database

Before working with tables, you need to select a database.

USE myapp;

This tells MySQL that you want to work inside the myapp database.


Understanding What Just Happened

  • You created a database
  • You checked available databases
  • You selected the database to work with

These are the first essential steps before creating tables or adding data.


Important Note

Every SQL command should end with a semicolon ;.

Without it, MySQL may not execute the command properly.


Common Beginner Mistakes

  • Forgetting to use the correct database
  • Missing the semicolon at the end of commands
  • Typing errors in database names

Pay attention to these small details as you practice.


Summary

In this lesson, you learned how to write your first SQL commands.

You created a database, viewed existing databases, and selected one to work with.

These commands form the foundation for everything you will do next in MySQL.

Share this tutorial