CSE132A F05 SQLpart1 - University of California, San Diego
CSE 132B
SQL as Query Language (Part I)
Some slides are based or modified from originals by Elmasri and Navathe,
Fundamentals of Database Systems, 4th Edition ? 2004 Pearson Education, Inc. and
Database System Concepts, McGraw Hill 5th Edition ? 2005 Silberschatz, Korth and Sudarshan
UCSD CSE132B
Slide 1/32
Basic Query Structure
SQL is based on set and relational operations with certain modifications and enhancements A typical SQL query has the form:
select A1, A2, ..., An from r1, r2, ..., rm where P
? Ai represents an attribute, Ri represents a relation ? P is a predicate.
This query is equivalent to the relational algebra
expression. A1,A2,K,An ( P (r1 ? r2 ? K? rm ))
The result of an SQL query is a relation.
UCSD CSE132B
Slide 2/32
The select Clause
The select clause list the attributes desired in the result of a query
? projection operation of relational algebra
Example: find the names of all branches in the loan relation:
select branch_name from loan In the relational algebra, the query would be: branch_name (loan)
UCSD CSE132B
Slide 3/32
The select Clause (Cont.)
SQL allows duplicates in query results.
? To force the elimination of duplicates, insert the keyword distinct after select.
Ex. Find the names of all branches in the loan relations, and remove duplicates
select distinct branch_name from loan
UCSD CSE132B
Slide 4/32
The select Clause (Cont.)
An asterisk in the select clause denotes "all attributes"
select * from loan
The select clause can contain arithmetic expressions involving the operation, +, ?, , and /, operating on constants or attributes.
The query: select loan_number, branch_name, amount 100 from loan
would return a relation similar to the loan relation, except that values for amounts are multiplied by 100.
UCSD CSE132B
Slide 5/32
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- null values cheriton school of computer science
- what does null mean springer
- introduction to algorithms and data structures
- working with null capable fields ibm
- range and null space
- null flavors cdisc
- lebesgue null sets college of arts and sciences
- firebird null guide
- cse132a f05 sqlpart1 university of california san diego
- range and null space stanford university
Related searches
- university high school san diego ca
- university of california essay prompts
- university of california supplemental essays
- university of california free tuition
- university of california campuses
- university of california online certificates
- preliminary change of ownership san diego ca
- address university of california irvine
- university of california at irvine ca
- university of california irvine related people
- university of california irvine staff
- university of california irvine employment