DBMS Unit 2.2 by Isometric.
DBMS Unit 2.2 by Isometric.
I
12
13
14 -- Tru nca te all dat a
from the tab le
res erv ati ons ;
I origin VARCHAR(50)
The origin city of the
flight.
I 17
I destination VARCHAR(50)
,
The destination city of
the flight.
I
I
The class of service
(e.g., Economy,
dass VARCHAR(50)
Business, First Class}.
0 SUBMIT
@ • Home Learn Anywhere•
... e index.sq!
~ ::::::
0
---A dd-t he•e mai l•co lum n
2.2.2. DDL -ALTER • Library System
Management t 1
alte r-ta ble- libr ary_ mem bers •add
•co~ umn •em ail•v arch ar(l OO) ;
to contact library 41 2
nt System and need to add functionality
You are enhancing a Library Manageme emb ers table by adding a new
must update the library_m
members via email. To achieve this, you help the library
the email addresses of members and will
column named email. This column will store ns.
book due dates, events, and notificatio
staff communicate with members about
Requirements:
• The column name should be ema il.
AR(l00).
• The column data type should beVARCH
column can store up to 100 characters.
• Ensure the ss initially.
s, as not all members may have an email addre
• The column should allow NULL value
requirement.
Write an SOL statement to implement this
DATE
.
JOlnDate DATE . JoinDa te
DECIM AL(l0,2 )
.
. fare
we DECIMALU0,2)
email VARCHAR(lOO)
.
po • logout(♦
• Support
[email protected] ...
.,'·'.•-,~-- -
•· ',:.t,e<
0 SUBMIT
(@ • Home Learn Anywhere•
e index.sq!
~ I
ers:
Table Schema for poli ce_ offic
I.■firs,:-Jarnc:
c;il\J ne
VARCHAR(50)
VARCHAR(50)
NOT NUL L
NOT NULL
■ a: I< VARCHAR(50)
I ">..lar DECIMAL(10,2)
ilI~~f'._
~.
_.,. .
• ,,.,.,. ...- ~ · --~t:"'l'.".":i,~ . ,,"'::'~
..... .-:,:·"··::"!, 0 SUBMIT
.-~ . ...'!!'fit .... ' •
~ i lndex.sql --~-:..=----..,,--------------.. •. . :':- ··•,t-' ,. ·.-;a,
(oo46)rfllO@@ c:=t .2
:l! ---T.ype-conten t•nere. • •
2.2.4. DDl: -Weather Monttoi'lng ~stem
. ~
I. • ;,.. '-<' . 1
@I 2 aroP.•ta};>le•WE ;~ttier_oata;
.You are working on a Weather Monitoring System thai collects real-time •weather data from various •••i
. .......... . . . •\!iii···• •• ••
.
regions. Recently, the system underwent a major QVerhaul, a~q all.data _from the old we~tper~data.
table has been success~lly mig[clt9;!_to a new stru~ture. As part o! th_,_ cleanup pr~ce~s~.t~t 9utda~e~ •
weather_d.ata table must be C9mpletely rem9ved from.me database tQ avoid an~ conflicts with the:i
new design. ·>1·
f~..::,
,, -:,\1: '•,' .,'.{!.~: ,_. • ·.•-~~~...
. . . --........ '
.. : '.'\ '., ' ,:fr/:
C: -s- lfil Q) :
.,
I..
,
-A
:
emp loy ees table schema
Con stra ints
Data Type
C umn Name
PRltvlAHY K'-'l
INT
e ::>loyeelD
NOT NULL
r.rstName VARCl-!AR(50)
I\JuT NULL
•. s:Na me VARCHAR(50)
b ,t1Date DATE
reO e DATE
Requirements:
loyees.
• The table name must be emp loyee.
uniquely identify each emp
elD colu mn will serve as the primary key to nam e is
• The employe g that eve ry emp loye e's
Nam e and last Nam e colu mns cannot be null, ensurin
• The first
recorded. ry valu es
ure only non-negative sala
de a check constraint to ens
• The salary column must inclu
are allowed.
___ --
---•·-r_
0 SUBMIT
@ • Home Learn Anywhere•
~ 5
0
Requirements: abase.
already exists in the dat
• The employees table to the table.
ed departme nt
• Add a new column nam data type VARCHAR(100).
uld hav e the
column department sho
• The each employee.
the department name for be assigned to a
• This column will store as not all employees may
column can acc ept NULL values initially,
• The
of addition.
department at the time
a:
employees table schem
C0nstrai ,ts
Oat:- "Type
ColLlmn r,.;ame
Pl~lr AR f Ki:-y
::-ployeelD • INT
11rstl',ame
VAR( ,~ 50 NO... '\IULL
,. m'"' t\JULL
VAR< \ '?I 0)
.c:_ • 1ame
tin Or:1te
r r,,..
Support l!>goutC♦ I
0 0 SUBMIT .. ,
@ • Home learn Anywhere•
ns in SQ L. 2
Gm ,A ·* ~ <P ~. I ~ s index.sq!
... .Q - · · - - - -
- •
~
n•C o} ~
•.
PRIMARY KEY
IN •
JeelD
m ;oyee~c1me
OEC"I 1/1 t1 ?
VARCI-< ~, "'O
umn
Tasks 1: Add a New Col
table.
mn nam ed designation to the em p
Add a new colu
tion
• Column Name: designa
100)
• Data Type: VARCHAR( the em p table.
be successfully add ed to
new column designation will
Expected Outcome: The
a Type of salary
Task 2: Change the Dat IMAL(10, 2) to FLOATS.
the salary column from DEC
Change the data type of
• Column Name: salary
• New Data Type: FLOAT8 ATS, allowing it to
mn will be updated to FLO
d Out com e: The dat a type of the salary colu
Exp ecte
store floating-point values.
a
-
,,
'$,.t"
•• ,:,I . . . ;,,·
."
... • - - , -.. - · · · - · · · - · ···- ,I , ~ "" . •
ue lO ii Uldll~a 111 UIV ~ , ... ,..... , ~1
rmanently delete the table alor:,g with all the data it holds.
Instructions:
• The employees table already exists in the database
•
se•
• Your task is to completely remove this table from the databa
delete the table and all of its data, so it cannot be recovered unless
•
• This action will permanently ., ..,,r
.."!/. .•
a backup is available.
the· database.
Write an SQL statement to drop the employees table from
Expected Outcome: .
• The employees table will be successfully removed
from the database•
• All data within the table will be permanently deleted and cannot be recovered unless a backup is
available.
le in the database.
: You ar~,no uired
.
to create the table, The table• is already availab
,.
•
-
,;'I,;·
•' ..
,.~
I-
1-; -
:·,,::,;. ~
1r.
••
LoqoutC♦~
-• w• ~-~.~:
: '• • , r • •
•
• Support
;ft!:~\ • .. ·• ..... ..... ....,,,.;J
I
•
• , ..,~..
~ ~ '
,'ff ~
,•
'
•~:•l
~-:~.>~ I ,•.
'
' ,
0 SUBMIT
re•
) • Home learn Anywhe
~ el index.sq! . j -- _, ' . .
Requirements: structu re
table, but keep the table's
jec tive : Remove all records from the employees
• Ob
ints) intact.
(columns, schema, constra re must remain unchanged
le must be clea red of data, but the column structu
• Outcome: The tab
rted in the future.
so that new data can be inse
ema:
em plo yee s table Sch
r.o st air, ts
Data l'Jpe
Colllmn Ha ...
Pnr 1a Vey
. INT
poyc"'ID
NO i NUL L
VARCt iAR (50
, ·IN.-. -t- /
NO T l'lUL L
Vt>QG L\R(50)
.:e.,NJme
U/1 E
',tr\1 1-ar t.
f)"'r F
tureOa'E:
0 SUBMIT
11
~
.... __1,:f__,£~__
e user.sq!
~Cr eate ;. the • st~~~ t • ~ao
0. DDL-1
base
i~ 11.-
~ v Cre ate •tab le•s. tud ent {'
,..,
re D
Column Name
t •r l '• I "I r 11 11, Vitt (
I• I
!11 l 'f I