26-04-2012, 03:01 PM
SQL
3.pdf (Size: 454.81 KB / Downloads: 61)
Data Definition Language
Allows the specification of not only a set of relations but alsoinformation about each relation, including:
The schema for each relation.
The domain of values associated with each attribute.
Integrity constraints
The set of indices to be maintained for each relations.
Security and authorization information for each relation.
The physical storage structure of each relation on disk.
Drop and Alter Table Constructs
The drop tablecommand deletes all information about the dropped relation from the database.
The alter tablecommand is used to add attributes to an existing relation:
alter table r add A D
where Ais the name of the attribute to be added to relation r and Dis the domain of A.
All tuples in the relation are assigned nullas the value for the new attribute.
The alter tablecommand can also be used to drop attributes of a relation:
The select Clause
SQL allows duplicates in relations as well as in query results.
To force the elimination of duplicates, insert the keyword distinct after select.
Find the names of all branches in the loanrelations, and remove duplicates
select distinct branch_name
from loan
The keyword all specifies that duplicates not be removed.