SQL Basic Tutorial
- Previous Page Server Script
- Next Page Basic Tutorial for Website Construction
SQL is the standard computer language used to access and process databases.
Managing data through SQL
Structured Query Language (SQL) is the standard language used to access databases, including SQL Server, Oracle, MySQL, Sybase, and Access, etc.
For those who want to store data in a database and retrieve data from it, knowledge of SQL is invaluable.
What is SQL?
- SQL is an acronym for Structured Query Language (Structured Query LLanguage)
- SQL enables us to access databases
- SQL is an ANSI standard computer language
- SQL is used to execute queries on the database
- SQL can retrieve data from the database
- SQL can insert new records into the database
- SQL can delete records from the database
- SQL is easy to learn
Editor's note:ANSI, American National Standards Institute
SQL is a standard - but...
SQL is an ANSI standard computer language used to access and operate database systems. SQL statements are used to retrieve and update data in the database. SQL can work with database programs such as MS Access, DB2, Informix, MS SQL Server, Oracle, Sybase, and other database systems.
Unfortunately, there are many different versions of the SQL language, but in order to be compatible with the ANSI standard, they must support some major keywords in a similar way (such as SELECT, UPDATE, DELETE, INSERT, WHERE, etc.).
Note:In addition to the SQL standard, most SQL database programs have their own private extensions!
SQL database table
A database typically contains one or more tables. Each table is identified by a name (such as "Customers" or "Orders"). Tables contain records (rows) with data.
The following example is a table named "Persons":
LastName | FirstName | Address | City |
---|---|---|---|
Hansen | Ola | Timoteivn 10 | Sandnes |
Svendson | Tove | Borgvn 23 | Sandnes |
Pettersen | Kari | Storgt 20 | Stavanger |
The table above contains three records (each corresponding to a person) and four columns (surname, name, address, and city).
SQL query program
Through SQL, we can query a database and obtain a result set returned.
Query programs are similar to this:
SELECT LastName FROM Persons
The result set is similar to this:
LastName |
---|
Hansen |
Svendson |
Pettersen |
Note:Some database systems require the use of a semicolon at the end of SQL commands. Semicolons are not used in our tutorials.
SQL Data Manipulation Language (DML)
SQL (Structured Query Language) is a syntax used to execute queries. However, the SQL language also includes syntax for updating, inserting, and deleting records.
These query and update statements come from the DML part of SQL:
- SELECT - Retrieve Data from Database Tables
- UPDATE - Update Data in Database Tables
- DELETE - Delete Data from Database Tables
- INSERT INTO - Insert Data into Database Tables
SQL Data Definition Language (DDL)
The DDL part of SQL allows us to create or delete tables. We can also define indexes (keys), specify links between tables, and impose constraints between tables.
The most important DDL statements in SQL:
- CREATE TABLE - Create New Table
- ALTER TABLE - Modify (Change) Database Table
- DROP TABLE - Delete Table
- CREATE INDEX - Create Index (Search Key)
- DROP INDEX - Delete Index
SQL Tutorial
Learn from the tutorials provided by CodeW3C.com SQL Tutorial.
- Previous Page Server Script
- Next Page Basic Tutorial for Website Construction