





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






of SQL are ย^ what the main
data definition language
( DDL ) commands of SQL are
โ^ double precision
double-precision
floating-point
number^ with
computer-
dependent precision โ^ float ( n )^
floating-point number with user specified precision of atleast^ n^ digits โ^ bit ( n )^
bit string of fixed length
n
โ^ bit varying
( n )^ bit string of variable length with user specified maximumlength
n โ^ blob^
binary large object
, byte sequence of variable length up to 4 GB, for the representation of extremely large objects(e.g. multimedia objects, video sequences, geo-objects) โ^ date^
calendar date with year (4 digits), month (2 digits), day (2digits), format: YYYY-MM-DD โ^ time^
time^ of^ day,^
in^ hours,^ minutes,
and^ seconds,
format:
HH:MM:SS โ^ time with time zone
time difference to GMT (6 digits) โ^ timestamp
value containing date and time of date โ^ interval^
relative value which can increment or decrement an abso-lute value of type
date ,^ time^ or
timestamp , year/month- or day/hour-intervals
ย^ unique^ expresses that this attribute is a candidate key. If a candidate key is formedby several attributes
A , ...,^ A , this is specified by the integrity constraint^1 n
unique ( A ,^1
...,^ A ). n Creation of a relation schema ย in SQL no relations but tables (duplicates allowed) ย creation of a schema with the aid of the clause create table^ R
, ...,^ A D , n^ n [< integrity constraint
, ..., < integrity constraint 1
]) k
R^ relation name,
A name of an attribute in the schema of relation i^
R ,^ D domain of i^
Ai
ย^ in BNF notation:^ create table
not null^ |^ unique
default^
null ] The exact treatment of integrity constraints is discussed later.
ย^ integrity constraints^ primary key
( A , ...,^ A ) jj^1 m The attributes^ A , ...,^ A form the primary key of jj^1 m^
ย^ example: university schema (with incomplete integrity constraints)^ create table
students(reg-id int not null
name^
varchar (30)^ not null
sem^
int , primary key^
(reg-id)) create table^ professors(pers-id^
int not null , name^
varchar (30)^ not null
room^
int^ unique , rank^
char (2), primary key^
(pers-id))
create table^ is_precondition_of(predecessor
int not null
successor^
int^ not null , primary key^
(predecessor, successor), foreign key^ (predecessor)
references^ lectures(id), foreign key^ (successor)
references^ lectures(id)) create table^ tests(reg-id^
int not null , id^
int not null , pers-id^
int not null , grade^
numeric (2,1), primary key^
(reg-id, id, pers-id), foreign key^ (reg-id)
references^ students(reg-id), foreign key^ (id)
references^ lectures(id), foreign key^ (pers-id)
references^ professors(pers-id))
Change of a relation schema ย^ adding a new attribute (a new column) by the clause^ โ^ alter table
add^
is only allowed if a default value is specified ย^ deleting an attribute (a column) from a relation by the clause^ alter table
drop^