Professional Documents
Culture Documents
ICT 2 - REGULAR
DATABASE MANAGEMENT SYSTEMS
PRACTICAL ASSIGNMENT
NAME:SARPONG RICHARD
INDEX NUMBER:06201219
A. WritetheSQLquerytograntdelete,insert,andupdateprivilegeonPersonalRecordtabletotheuserSCO
TT.
ANS:GRANTINSERT,DELETE,UPDATEONPRSONALRECORD.*TO‘SCOTT’@’LOCALHOST’;
B.Asauserwithanadministrativeright,writetheSQLquerytochangethepasswordoftheuserSCOTTtoGOOD.
ANS:ALTERUSER‘SCOTT’@’LOCALHOST’IDENTIFIEDBY‘GOOD’;
C.WriteanSQLcommandusedtocreatethePersonalRecordtablewhereIndexNumisthePrimarykey.
ANS:CREATETABLEPERSONALRECORD(INDEXNUMINT,SURNAMEVARCHAR(10),OTHERNAMEVARCHAR(1
0),INDEXNUMPRIMARYKEY);
D.WritetheappropriateSQLcommandtoinsertthefirstthreerecordsintothestd_persoanltable.
ANS:
INSERTINTOPERSONALRECORD(INDEXNUM,SURNAME,OTHERNAME,GENDER)VALUE
(‘001’,’Yeboah’,’KOFI’,’M’);
INSERTINTOPERSONALRECORD(INDEXNUM,SURNAME,OTHERNAME,GENDER)VALUE
(‘002’,’AMARTEY’,’ESINAM’,’F’);
INSERTINTOPERSONALRECORD(INDEXNUM,SURNAME,OTHERNAME,GENDER)VALUE
(‘003’,’kUNADU’,’ESTHER’,’F’);
E.TabulatetheresultifthefollowingSELECTqueryoperationsareusedtoquerythedatabase.
i.SELECTp.Index_NumASIndex_Number,CONCAT(p.Surname‘‘p.Othernames)ASFullname,a.CourseASSubj
ect,a.MarksASMarksFROMPersonalRecordpJOINAcademicRecordaON(p.Index_Num=a.Index_Num)WHE
REa.Marks<81;
ANS:
ii.SELECTIndex_Num,Course,MarkFROMAcademicRecordWHERECourse=‘DiscreteMaths’ANDMark>80O
RDERBYMarksASC;
ANS:
F.WriteanSQLquerytochangetheGenderofKonaduEstherfrom‘F’to‘M’inthePersonalRecordtable.
ANS:UPDATEPERSONALRECORDSETGENDER='M'WHEREINDEXNUM=003;
G.WriteanSQLquerytoaddanewcolumnorfield,DOBtothePersonalRecordtable.
ANS:ALTERTABLEPERSONALRECORDADDDOBINT;
H.WriteanSQLquerytocompletelydeletetheAcademicRecordtable.
ANS:DROPTABLEACADEMICRECORD;