Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Dat

aBase(
DB)
sect
ion2
1)Howt
obui
l
ddat
abase?
2)DDL"
CREATE"
?
3)DML"
INSERT"?
4)user"
hr"?

>>connsy
stem
>>passwor
d:sy
s
>>cr
eat
euseral
ii
dent
if
iedbyal
i
;
>>gr
antal
lpr
ivi
l
egest
oal
i
;
>>connal
i
>>passwor
d:al
i
>>showuser
;
1)Howt
obui
l
dDat
abase?
· DB:I
tisasetoft
abl
es,
exceptt
hat
t
her
eisar
elat
ionshi
pbet
weent
hem

·t
abl
e:

-at
tri
but
es=f
iel
ds=col
umn=I
D,Fi
rst
Name,
LastName,
Emai
l
,YearofBi
rt
h=

-at
tri
but
eval
ues= 1,
pet
er,
l
ee,
2,
joe,
1992

-r
ecor
d=r
ow=
1,
pet
er,
l
ee,
plee@uni
ver
sit
y.edu,
1992

2)DDL"
CREATE"
?
·t
ocr
eat
etabl
ewi
thsqli
nor
acl
e:
>>cr
eat
e t
abl
e t
abl
e-name(
col
umn1
dat
aty
pe,
col
umn2 dat
aty
pe,
col
umn3dat
aty
pe,
col
umn-
n dat
aty
pe)
;

-t
abl
ename:
-dat
aty
pes

-exampl
e1:
creat
etabl
est
udent
(
id,
name,
grade,
depar
tment
)
>>createtabl
est udent
(i
dchar(
3),
name
varchar2(20),
grade
number (4,
1),
depar t
mentchar
(2))
;

e2:
-exampl cr
eat
etabl
e
empl
oyees(
emp_
id,
emp_
name,
Bi
rt
hdat
e,sal
ary
)
>>createtabl
eemploy
ees(emp_id
char(3),
emp_name varchar
2(20),
Bir
thdat
e
date,sal
arynumber
(5)
);
>>descst
udent
;

2)DML"
INSERT"
?
·t
oinser
tdat
aint
otabl
ewi
thsqli
n
or
acl
e:
>>i
nser
tinto
t
able_name(colunm1,col
umn2,
col
umn3)
v
alues(1,
"mai"
,75,"
is"
);
>>i
nser
tint
ost
udentv
alues(
2,"
esr
aa"
,59,
"i
t"
);

-exampl
e1:i
nser
tthi
sdat
aint
o
st
udent
"1,
aya,
87,
i
s"
"
2,al
i
,90,
i
t"
"
3,hoda,
76,
cs"
>>i
nser
tint
ost
udentv
alues(
1,'
aya'
,
78,
'
is'
);
>>i
nser
tint
ost
udent
(i
d,name,
grade,
depar
tment
)
v
alues(
2,'
al
i'
,
90,
'
cs'
);

-exampl
e2: i
nser
tthi
sval
uesi
ntoempl
oyees
"
1,ahmed,
2/2/
1998,
2500" "
2,sal
ma,
30/
5/1997"
>>inser
tint
o
empl oy
ees(emp_i
d,emp_
name,Bir
thdat
e,sal
ary
)val
ue
s(1,'
ahmed'
,'
02-
feb-
1998'
,2500)
;
>>i
nser
tint
oemploy
ees
val
ues(
2,'
sal
ma'
,
'30-
mai
-1997'
,
3500)
;

-Howt
oinser
tnul
lval
ue:
1)
iml
ici
t
>>inser
tint
ost
udent
(i
d,name)
v
alues(
4,'
asmaa')
;
2)
expl
ici
t
>>i
nser
tintost
udent
v
alues(
5,'
ahmed',
nul
l,
nul
l
);
t
ask:
inser
tdat
aint
otabl
edur
ing
r
un?

4)user"
hr"?
hr:i
sreadyuseri
nor
acl
e
-t
oconnecthr
>>connsy
stem
>>passwor
d:sy
s
>>al
teruserhri
dent
if
iedbyhraccount
unl
ock;
>>connhr
>>passwor
d:hr

You might also like