SQL Tutorial – For Beginners and Advanced Users

What is SQL

The SQL stands for Structured Query Language, is a computer language designed to retrieve and manage data in the relational databases. The SQL is an ANSI standard which stands for American National Standards Institute.

SQL is pronounced as the sequel, as well.

There are many relational databases in the market. A few popular includes MySQL, MS SQL server, MS Access, Oracle and IBM’s DB2.

Where Relational Database Management System is a DBMS which is based on the relational model introduced by E.F.Codd.

SQL is the standard for performing operations including create, update, delete data in RDBMS, however, different providers use dialects such as:

  • MS SQL Server uses Transact-SQL (T-SQL)
  • Oracle uses PL/SQL

As a database student, you should learn SQL generally, as this SQL tutorial will take you through. With that, you can work on any RDBMS for standard operations. Certain SQL commands or statements are common to each database like the Select statement to query data from the DB tables. Similarly, Update data, to modify data in the tables, Delete data, Where clause etc. are kept compliant to the ANSI standards by different providers.

However, there are different things in different RDBMS like syntax, data types, doing programming at the database level etc. For that, please follow the related documentation of that specific database.

Purpose of this tutorial

This tutorial will explain standard SQL commands in its respective chapters. The SQL commands can be categorized into the following:

  • Data Definition language (DDL) that includes Create, Alter Drop commands.
  • Data Manipulation Language (DML) that includes Insert, Update and Delete.
  • Data Control Language (DCL) that includes Grant, Revoke.
  • Data Query Language (DQL) that includes the Select statement

The tutorial will address each of the above statements in general and wherever required references of the particular database is given. Generally, we will use the MySQL and MS SQL server to execute different commands for this tutorial examples. The MySQL is freely available while the standard version of MS SQL server can also be found free.

This is the SQL tutorial for beginners who are just started learning what database and SQL is. Also, it covers advanced level SQL topics for advanced learners.

Examples in this SQL tutorial

Almost each of the chapter in this tutorial contains examples that you can run in the database. A screenshot of each example is linked that shows the output of the SQL command. You can click on “See the graphic of this table with data” link with each tutorial to see the demonstration of the respective SQL commands.

Applying SQL skills

Learning SQL and being experienced in SQL is quite necessary these days in order to work and apply skills as a programmer.

High-level experience may lead you as a database administrator, however, equipping yourself at beginners or mediocre level will help you developing small to medium sized web applications or desktop software or even mobile applications. As such, the modern application at any level uses the database to store different kind of data.

Table of content

Chapters in this tutorial:

  1. SQL Tutorial
  2. SQL create database
    1. drop database
  3. How to create table
    1. Primary key in SQL
    2. How to drop table
  4. Insert statement
    1. Insert with values
    2. Insert with select
  5. The Update statement
    1. SQL update select
  6. SQL Delete
    1. SQL Truncate
  7. The Select statement
  8. SQL Alter statement
  9. SQL Where clause
  10. SQL Between clause
  11. SQL IN
  12. SQL Like operator
  13. The Order by
  14. The Group by
  15. SQL Having
  16. SQL Functions
    1. The Count function
    2. The Sum function
    3. The Max function
    4. SQL Min
    5. SQL Avg
  17. SQL Distinct clause
  18. SQL Joins
    1. The inner join
    2. The left join
    3. The right join
    4. The full outer join