Home | Courses | SQL Lesson 1

SQL Menu

Lesson 1 >
Lesson 2

Lesson 3
Lesson 4

Lesson 5
Lesson 6
Lesson 7

 

Computer Menu

ASP
HTML
XML
JAVA
SQL
XHTML
HARDWARE
NETWORKING

 

More Courses...

 TrainingTools

Free web based courses. Learn all the softwares used for designing.

 

 W3Schools

Full Web Building Tutorials. From basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP.

 

 Java Courses

A big collection of JAVA script courses offered by Sun Microsystems.

 


 

SQL

  °  SQL  (Structured Query Language) 
    
TUTORIAL-----------------------------------------------------------------------------

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

The SELECT Statement

The SELECT statement selects columns of data from a database.

Use it to SELECT information FROM a table like this:

SELECT column_name(s) FROM table_name

 

Example: Select Columns from a Table

To select the columns named "LastName" and "FirstName", use a SELECT statement like this:

SELECT LastName,FirstName FROM Persons

The "Persons" table:

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

The result:

LastName FirstName
Hansen Ola
Svendson Tove
Pettersen Kari


Example: Select all Columns

To select all columns from the "Person" table, use a * symbol instead of column name like this: 

SELECT * FROM Persons

The result:

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

 

NEXT Lesson»

 


 

 

 


Home | Free Mail | Forum | ePals | eCards | Chat | Downloads | Education | Music | Horoscope | Magic | Email us

 

© 2004 Whoo-ee!. All rights reserved.

For your suggestions: suggestion@whoo-ee.com