Information Technology Reference
In-Depth Information
2.3.2
Structured Query Language (SQL)
SQL was introduced as the standard query language for relational DBMS. The basic
structure of an SQL retrieval command, a Select statement, is as follows:
1
, A
2
, … A
n
1
, r
2
…. r
n
[where P]
[order by O]
[group by G]
[having H]
All classes within the square brackets are optional. The A
i
represents attributes, the
r
i
represents relations, and P is a predicate, and is default to be true. The attribute
A
i
may be replaced with a asterisk (*) to select all attributes of all relations appear-
ing in the form clause. O is the sort order of the target tuples based upon attribute
values. G is the display group of the target attributes. H is the selection criteria of
the display groups.
For example, if we use the normalized relations as source, we can issue the fol-
lowing select statements:
• Toretrievethestudent#ofallstudents
Select Student# from Student
• Toretrievethestudent#ofallstudentswhoaretakingCS101
Select Student# from Enroled-Student
where Class# = CS101
• Toretrievethestudent#ofallstudentswhoaretakingCS101andwhosegrade
is A
Select Student# from Enroled-Student
where Class# = CS101 and Grade = A
Search WWH ::
Custom Search