- SQL Tutorial
- SQL - Home
- SQL - Overview
- SQL - RDBMS Concepts
- SQL - Databases
- SQL - Syntax
- SQL - Data Types
- SQL - Operators
- SQL - Expressions
- SQL Database
- SQL - Create Database
- SQL - Drop Database
- SQL - Select Database
- SQL - Rename Database
- SQL - Show Databases
- SQL - Backup Database
- SQL Table
- SQL - Create Table
- SQL - Show Tables
- SQL - Rename Table
- SQL - Truncate Table
- SQL - Clone Tables
- SQL - Temporary Tables
- SQL - Alter Tables
- SQL - Drop Table
- SQL - Delete Table
- SQL - Constraints
- SQL Queries
- SQL - Insert Query
- SQL - Select Query
- SQL - Select Into
- SQL - Insert Into Select
- SQL - Update Query
- SQL - Delete Query
- SQL - Sorting Results
- SQL Views
- SQL - Create Views
- SQL - Update Views
- SQL - Drop Views
- SQL - Rename Views
- SQL Operators and Clauses
- SQL - Where Clause
- SQL - Top Clause
- SQL - Distinct Clause
- SQL - Order By Clause
- SQL - Group By Clause
- SQL - Having Clause
- SQL - AND & OR
- SQL - BOOLEAN (BIT) Operator
- SQL - LIKE Operator
- SQL - IN Operator
- SQL - ANY, ALL Operators
- SQL - EXISTS Operator
- SQL - CASE
- SQL - NOT Operator
- SQL - NOT EQUAL
- SQL - IS NULL
- SQL - IS NOT NULL
- SQL - NOT NULL
- SQL - BETWEEN Operator
- SQL - UNION Operator
- SQL - UNION vs UNION ALL
- SQL - INTERSECT Operator
- SQL - EXCEPT Operator
- SQL - Aliases
- SQL Joins
- SQL - Using Joins
- SQL - Inner Join
- SQL - Left Join
- SQL - Right Join
- SQL - Cross Join
- SQL - Full Join
- SQL - Self Join
- SQL - Delete Join
- SQL - Update Join
- SQL - Left Join vs Right Join
- SQL - Union vs Join
- SQL Keys
- SQL - Unique Key
- SQL - Primary Key
- SQL - Foreign Key
- SQL - Composite Key
- SQL - Alternate Key
- SQL Indexes
- SQL - Indexes
- SQL - Create Index
- SQL - Drop Index
- SQL - Show Indexes
- SQL - Unique Index
- SQL - Clustered Index
- SQL - Non-Clustered Index
- Advanced SQL
- SQL - Wildcards
- SQL - Comments
- SQL - Injection
- SQL - Hosting
- SQL - Min & Max
- SQL - Null Functions
- SQL - Check Constraint
- SQL - Default Constraint
- SQL - Stored Procedures
- SQL - NULL Values
- SQL - Transactions
- SQL - Sub Queries
- SQL - Handling Duplicates
- SQL - Using Sequences
- SQL - Auto Increment
- SQL - Date & Time
- SQL - Cursors
- SQL - Common Table Expression
- SQL - Group By vs Order By
- SQL - IN vs EXISTS
- SQL - Database Tuning
- SQL Function Reference
- SQL - Date Functions
- SQL - String Functions
- SQL - Aggregate Functions
- SQL - Numeric Functions
- SQL - Text & Image Functions
- SQL - Statistical Functions
- SQL - Logical Functions
- SQL - Cursor Functions
- SQL - JSON Functions
- SQL - Conversion Functions
- SQL - Datatype Functions
- SQL Useful Resources
- SQL - Questions and Answers
- SQL - Quick Guide
- SQL - Useful Functions
- SQL - Useful Resources
- SQL - Discussion
SQL Tutorial: Learn SQL for Free
SQL Tutorial
Our SQL tutorial helps you learn SQL (Structured Query Language) in simple and easy steps so that you can start your database programming quickly. It covers most of the important concepts related to SQL for a basic to advanced understanding of SQL and to get a feel of how SQL works.
SQL (Structured Query Language) is a programming language which is used to manage data stored in relational databases like MySQL, MS Access, SQL Server, Oracle, Sybase, Informix, Postgres etc.
SQL is a database computer language designed for the retrieval and management of data in a relational databases like MySQL, MS Access, SQL Server, Oracle, Sybase, Informix, Postgres etc. SQL stands for Structured Query Language. SQL was developed in the 1970s by IBM Computer Scientists.
SQL is not a database management system, but it is a query language which is used to store and retrieve the data from a database or in simple words SQL is a language that communicates with databases.
SQL Examples
Consider we have following CUSTOMERS table which stores customer's ID, Name, Age, Salary, City and Country −
ID | Name | Age | Salary | City | Country |
---|---|---|---|---|---|
1 | Ramesh | 32 | 2000.00 | Maryland | USA |
2 | Mukesh | 40 | 5000.00 | New York | USA |
3 | Sumit | 45 | 4500.00 | Muscat | Oman |
4 | Kaushik | 25 | 2500.00 | Kolkata | India |
5 | Hardik | 29 | 3500.00 | Bhopal | India |
6 | Komal | 38 | 3500.00 | Saharanpur | India |
7 | Ayush | 25 | 3500.00 | Delhi | India |
SQL makes it easy to manipulate this data using simple DML (Data Manipulation Language) Statements. For example, if we want to list down all the customers from USA then following will be the SQL query.
SELECT * FROM CUSTOMERS WHERE country = 'USA';
This will produce the following result:
ID | Name | Age | Salary | City | Country |
---|---|---|---|---|---|
1 | Ramesh | 32 | 2000.00 | Maryland | USA |
2 | Mukesh | 40 | 5000.00 | New York | USA |
SQL Online Editor
We have provided SQL Online Editor which helps you to Edit and Execute the SQL code directly from your browser. Try to click the icon to run the following SQL code to be executed on CUSTOMERS table and print the records matching with the given condition.
SELECT * FROM CUSTOMERS WHERE country = 'USA';
So now, you do not need to do a sophisticated setup to execute all the examples given in this tutorial because we are providing you Online SQL Editor, which allows you to edit your code and compile it online. You can try our Online SQL Editor.
SQL Basic Commands
We have a list of standard SQL commands to interact with relational databases, These commands are CREATE, SELECT, INSERT, UPDATE, DELETE, DROP and TRUNCATE and can be classified into the following groups based on their nature −
Data Definition Language (DDL)
A Data Definition Language (DDL) is a computer language which is used to create and modify the structure of database objects which include tables, views, schemas, and indexes etc.
Command | Description | Demo |
---|---|---|
CREATE | Creates a new table, a view of a table, or other object in the database. | Demo |
ALTER | Modifies an existing database object, such as a table. | Demo |
DROP | Deletes an entire table, a view of a table or other objects in the database. | Demo |
TRUNCATE | Truncates the entire table in a go. | Demo |
Data Manipulation Language (DML)
A Data Manipulation Language (DML) is a computer programming language which is used for adding, deleting, and modifying data in a database.
Command | Description | Demo | SELECT | Retrieves certain records from one or more tables. | Demo |
---|---|---|
INSERT | Creates a record. | Demo |
UPDATE | Modifies records. | Demo |
DELETE | Deletes records. | Demo |
Data Control Language (DCL)
Data Control Language (DCL) is a computer programming language which is used to control access to data stored in a database.
Command | Description | Demo | GRANT | Gives a privilege to user | Demo |
---|---|---|
REVOKE | Takes back privileges granted from user. | Demo |
Why to Learn SQL?
SQL (Structured Query Language) is a MUST for the students and working professionals to become a great Software Engineer specially when they are working in Software Development Domain. SQL is the most common language used almost in every application software including banking, finance, education, security etc. to store and manipulate data.
SQL is fairly easy to learn, so if you are starting to learn any programming language then it is very much advised that you should also learn SQL and other Database related concepts to become a complete Software Programmer. There are many good reasons which makes SQL as the first choice of any programmer −
SQL is the standard language for any Relational Database System. All the Relational Data Base Management Systems (RDBMS) like MySQL, MS Access, Oracle, Sybase, Informix, Postgres and SQL Server use SQL as their standard database language.
Also, software industry is using different dialects of SQL, such as −
MS SQL Server using T-SQL,
Oracle using PL/SQL,
MS Access version of SQL is called JET SQL (native format) etc.
SQL Applications
SQL is one of the most widely used Query Language over the databases. SQL provides following functionality to the database programmers −
Execute different database queries against a database.
Define the data in a database and manipulate that data.
Create data in a relational database management system.
Access data from the relational database management system.
Create and drop databases and tables.
Create and maintain database users.
Create view, stored procedure, functions in a database.
Set permissions on tables, procedures and views.
Who Should Learn SQL
This SQL tutorial will help both students as well as working professionals who want to develop applications based on some databases like banking systems, support systems, information systems, web websites, mobile apps or personal blogs etc. We recommend reading this tutorial, in the sequence listed in the left side menu.
Today, SQL is an essential language to learn for anyone involved in the software applicatipon development process including Software Developers, Software Designers, and Project Managers etc.
Prerequisites to Learn SQL
Though we have tried our best to present the SQL concepts in a simple and easy way, still before you start learning SQL concepts given in this tutorial, it is assumed that you are already aware about some basic concepts of computer science, what is a database, especially the basics of RDBMS and associated concepts.
This tutorial will give you enough understanding on the various concepts of SQL along with suitable examples so that you can start your Software Development journey immediately after finishing this tutorial.
SQL Online Quizzes
This SQL tutorial helps you prepare for technical interviews and certification exams. We have provided various quizzes and assignments to check your learning level. Given quizzes have multiple choice type of questions and their answers with short explanation.
Following is a sample quiz, try to attempt any of the given answers:
Q 1 - The SQL programming language was developed by which of the following:
Answer : C
Explanation
The SQL programming language was developed in the 1970s by IBM researchers Raymond Boyce and Donald Chamberlin.
Start your online quiz Start SQL Quiz.
SQL Jobs and Opportunities
SQL professionals are very much in high demand as the data turn out is increasing exponentially. Almost every major company is recruiting IT professionals having good experience with SQL.
Average annual salary for a SQL professional is around $150,000. Though it can vary depending on the location. Following are the great companies who keep recruiting SQL professionals like Database Administrator (DBA), Database Developer, Database Testers, Data Scientist, ETL Developer, Database Migration Expert, Cloud Database Expert etc:
- Amazon
- Netflix
- Infosys
- TCS
- Tech Mahindra
- Wipro
- Uber
- Trello
- Many more...
So, you could be the next potential employee for any of these major companies. We have developed a great learning material for SQL which will help you prepare for the technical interviews and certification exams based on SQL. So, start learning SQL using our simple and effective tutorial anywhere and anytime absolutely at your pace.
Frequently Asked Questions about SQL
There are some very Frequently Asked Questions(FAQ) about SQL, this section tries to answer them briefly.
SQL skills help software programmers and data experts maintain, create and retrieve information from relational databases like MySQL, Oracle, MS SQL Server etc., which store data into columns and rows. It also allows them to access, update, manipulate, insert and modify data in efficient way.
A relational database stores information in tabular form, with rows and columns representing different data attributes and the various relationships between the data values.
There are 5 main types of commands. DDL (Data Definition Language) commands, DML (Data Manipulation Language) commands, and DCL (Data Control Language) commands, Transaction Control Language(TCL) commands and Data Query Language(DQL) commands.
SQL is very easy to learn. You can learn SQL in as little as two to three weeks. However, it can take months of practice before you feel comfortable using it. Determining how long it takes to learn SQL also depends on how you plan to use it. Following this SQL tutorial will give you enough confidence to work on any software development related to database.
SQL queries are also more flexible and powerful than Excel formulas and SQL is fast which can handle large amount of data. Unlike Excel, SQL can handle well over one million fields of data with ease.
Here are the summarized list of tips which you can follow to start learning SQL.
- First and the most important is to make your mind to learn SQL.
- Install MySQL or MariaDB database on your computer system.
- Follow our tutorial step by step starting from very begining.
- Read more articles, watch online courses or buy a book on SQL to enhance your knowledge in SQL.
- Try to develop a small software using PHP or Python which makes use of database.
Following are four basic SQL Operations or SQL Statements.
- SELECT statement selects data from database tables.
- UPDATE statement updates existing data into database tables.
- INSERT statement inserts new data into database tables.
- DELETE statement deletes existing data from database tables.
Following are following three SQL data types.
- String Data types.
- Numeric Data types.
- Date and time Data types.
You can use our simple and the best SQL tutorial to learn SQL. We have removed all the unnecessary complexity while teaching you SQL concepts. You can start learning it now Start Learning SQL.