SQL Commands is a website demonstrating how to use the most frequently used SQL clauses. SQL Commands is not a comprehensive SQL Tutorial, but a simple guide to SQL clauses available online for free.
Our SQL Commands reference will show you how to use the SELECT, DELETE, UPDATE, and WHERE SQL commands. Each of the SQL commands articles is illustrated with practical examples, designed to help you learn the SQL commands syntax. You can also do the SQL practice exercises at the end of each tutorial.
A relational database consists of various database objects including but not limited to tables, views, stored procedures, user-defined functions, and triggers. Let’s have a look at database tables first.
All the information in a database is stored in tables, which are identified by name. Each table consists of rows and columns. Each of the db table columns is identified by name and it has a specific data type. The rows store the information saved in the table. Here is how a simple table looks like:Table Cities
|3||New York||New York|
We can divide the SQL commands in several major categories depending on their purpose - Data Definition Language (DDL), Data Control Language (DCL), Data Query Language (DQL), and Data Manipulation Language (DML).
Before we can retrieve or manipulate data we need to create database objects like table so we can store some information there. We can use the DDL command CREATE to create a table:
After we have created our table we can use the INSERT SQL statement (DML) to enter some data in it.
In our 4th statement above we made a mistake, and entered ‘Texas’ as a state for Seattle, so we can correct that we another SQL DML command UPDATE:
We used the WHERE SQL clause to specify that we want to update only the record with CityID of 4. Of course we can decide that we don’t need the Seattle record at all and we can delete it with the following statement:
One of the most important tasks when working with SQL is retrieving data from database tables. We do that using the SQL SELECT command:
The above SQL command will retrieve all rows from the database table. You can also order the results of your SQL query by one or more columns:
You can also retrieve data conditionally using SQL WHERE clause:
To learn in more detail about each of the SQL commands above please use the left navigation menu and watch our “Introduction to SQL Commands” video below.
If you have any question or concerns please contact us at: