HOME

SQL Basic
SQL HOME
SQL Introduction
SQL Select
SQL Where
SQL And & Or
SQL Between
SQL Distinct
SQL Order By
SQL Try It
SQL Insert
SQL Update
SQL Delete
SQL Count

SQL Advanced
SQL Functions
SQL Group By
SQL Aliases
SQL Join
SQL Create
SQL Alter

SQL Quiz
SQL Quiz Test
Award Winning Web Host Full Services Including Ecommerce
Please visit our sponsors !

Introduction to SQL

previous next

SQL is an ANSI standard language for accessing databases.


What is SQL?

  • SQL stands for Structured Query Language
  • SQL allows you to access a database
  • SQL is an ANSI standard language
  • SQL can execute queries against a database
  • SQL can retrieve data from a database
  • SQL can insert new records in a database
  • SQL can delete records from a database
  • SQL can update records in a database
  • SQL is very easy to learn

SQL is a Standard

SQL is an ANSI (American National Standards Institute) standard for accessing database systems. SQL statements are used to retrieve and update data in a database.

SQL works with database programs like Access, DB2, Informix, Microsoft SQL Server, Oracle, Sybase, and many others (but unfortunately most of them also have their own proprietary extensions to the language).


Database Tables

Databases contain objects called Tables.

Records of data are stored in these tables. Tables are identified by names (like "Persons", "Orders", "Suppliers").

Tables contain Columns and Rows with data. Rows contain records (like one record for each person). Columns contain data (like First Name, Last Name, Address, and City).

Here is an example of  a Table called "Persons":

LastName FirstName Address City
Hansen Ola Timoteivn 10 Sandnes
Svendson Tove Borgvn 23 Sandnes
Pettersen Kari Storgt 20 Stavanger

LastName, FirstName, Address, and City are table Columns. The Rows contain 3 records about 3 persons.


SQL Queries

With SQL, we can Query a database and have a Result returned in a tabular form.

A Query like this:

SELECT LastName FROM Persons

Will give a Result like this:

LastName
Hansen
Svendson
Pettersen

Note: Some database systems require a semicolon at the end of the SQL statement. We don't use the semicolon in our tutorials.


SQL Data Manipulation

As the name suggests, SQL is a syntax for executing queries. But the SQL language also includes a syntax to update records, insert new records and delete existing records.

These query and update commands together form the Data Manipulation Language (DML) part of SQL: 

  • SELECT - extracts data from a database
  • UPDATE - updates data in a database
  • DELETE - deletes data from a database
  • INSERT - inserts new data into a database

SQL Data Definition

The Data Definition Language (DDL) part of SQL permits database tables to be created or deleted. We can also define indexes (keys), specify links between tables, and impose constraints between database tables.

The most important DDL statements in SQL are: 

  • CREATE TABLE - creates a new database table
  • ALTER TABLE - alters (changes) a database table
  • DROP TABLE - deletes a database table
  • CREATE INDEX - creates an index (search key)
  • DROP INDEX - deletes an index

SQL and Active Server Pages

SQL is an important part of ASP, because the Active Data Object (ADO) used in ASP to access databases, rely on SQL for data access.

If you want to know more about ASP and ADO:

Study our ASP tutorial, and our ADO tutorial.


previous next

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

IISProtect
Password Protect
Your Web Pages



Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search