7
Tutorial 6 SQL Muhammad Sulayman [email protected]

Tutorial 6 SQL Muhammad Sulayman [email protected]

Embed Size (px)

Citation preview

Page 1: Tutorial 6 SQL Muhammad Sulayman msul028@ec.auckland.ac.nz

Tutorial 6 SQL

Muhammad [email protected]

Page 2: Tutorial 6 SQL Muhammad Sulayman msul028@ec.auckland.ac.nz

SQL - Background

SQL, stands for Structured Query Language, is the most influential commercially marketed query language.

IBM developed the original version of SQL at its San Jose Research Laboratory and implement it (called as Sequel) as part of the System R project in the early 1970s. Now SQL is the standard relational-database language.

The SQL standard is controlled by American National Standards Institute (ANSI) and the International Organization for Standardization (ISO).

Page 3: Tutorial 6 SQL Muhammad Sulayman msul028@ec.auckland.ac.nz

SQL - Introduction

The SQL language has several parts (3): DDL, Data-definition language, is used to

define relation schemas, deleting relations, and modifying relation schemas;

DML, Interactive data-manipulation language, includes commands to query tuples from, Insert tuples into, delete tuples from and modify tuples in the database;

And other things, such as view definition, transaction control and etc. DCL (data control language)

Page 4: Tutorial 6 SQL Muhammad Sulayman msul028@ec.auckland.ac.nz

SQL – Basic commands

Note: simple but informal syntax! Create a table:

CREATE TABLE <Table_Name> (Attribute_Definitions)

Delete a table:DROP TABLE <Table_Name>

Query:SELECT [DISTINCT] Select_Expression,...FROM Table_References[WHERE Where_Definition]

Page 5: Tutorial 6 SQL Muhammad Sulayman msul028@ec.auckland.ac.nz

SQL – Basic commands

Insert:INSERT INTO <Table_Name> [(ColmnList)] VALUES(DataList)

Delete:DELETE FROM <Table_Name> [WHERE Where_Definition]

Update:UPDATE <Table_Name> SET Column_Name1=Expression1, [Column_Name2=Expression2, ...] [WHERE Where_Definition]

Page 6: Tutorial 6 SQL Muhammad Sulayman msul028@ec.auckland.ac.nz

SQL - Resources

Reference - Introduction to Structured Query Language:

http://www.cs.auckland.ac.nz/references/sql/sqlTutorial.pdf

Page 7: Tutorial 6 SQL Muhammad Sulayman msul028@ec.auckland.ac.nz

Exercise Time!