What is SQL?
SQL stands for "Standard Query Language". It's a powerful language which is being used in many Database Management Systems nowadays. It's primary purpose is to enable users to manipulate and interact with databases.
SQL and DBMSs
SQL comes in many versions such as PL/SQL or Transact-SQL and many others. In general, all of these version are based upon the ANSI SQL Standard (American National Standards Institute). All DBMSs allow users to interact with a database using a graphical user interface. In the end, all those commands issued by the user are converted into SQL by the DBMS application.
Using SQL
When you are faced with SQL syntax, you might feel overwhelmed due to the amount of tags available for you to use. An SQL statement can certainly be written in many ways but in all, it's very straightforward.
SQL is divided into 2 sublanguages:
1) Data Definition Language
This set includes all commands that enable you to create and structure databases and database objects.
2) Data Manipulation Language
This set includes all commands that enable you to insert, retrieve and alter data within the databases created.
SQL commands examples
In this section will cover the most important commands used in SQL
You may also visit the following website for more SQL tutorials:
http://www.w3schools.com/sql/default.asp
We will display examples of the following commands:
insert, select, update, delete
INSERT
This command allows use to insert records into a table.
INSERT INTO orders
VALUES('12342', 'john', 'smith', '$545.55')
Explanation: orders is the table name and the values reflect the following fields (orderid, first name, last name, order total)
UPDATE
This command allows you to update certain fields within a recordset in a table
UPDATE orders
SET ordertotal = '$99.88'
WHERE orderid = '12342'
Explanation: we are updating the order total value for orderid 12342 to $99.88 in orders table
SELECT
This command allows you to retrieve defined fields within a table based on a condition. YOu may also simply retrieve all records in a table with no condition specified.
SELECT *
FROM orders
WHERE orderid = '12342'
Explanation: We are asking for all "*" fields within this recordset for orderid "12342".
References:
1) http://www.w3schools.com/SQL/sql_intro.asp
2) http://databases.about.com/od/sql/a/sqlbasics.htm
3) http://databases.about.com/od/sql/a/sqlfundamentals.htm
