1. script
untukmembuattabel-tabel yang lain :
Tabeljenis_service
CREATE
TABLE JENIS_SERVICE(
KD_JENIS
CHAR(3) CONSTRAINT PK_JENIS PRIMARY KEY
JENIS_SERVICE
VARCHAR(20) NOT NULL,
TARIF
Int)
Tabeldetail_service
CREATE
TABLEDETAIL_SERVICE (
NO_SERVICE
INT IDENTITY(1,1) REFRENCES SERVICE_MOTOR NO_SERVICE
KD_JENIS
CHAR(3) REFRENCES JENIS_SERVICE (KD_JENIS)
2.
TambahankolomJumlahtipe
integer nilai default=1 padatabelDetail_Service.
ALTER
TABLE JUMLAH DETAIL_SERVICE
ADD
JUMLAH INT DEFAULT = 1;
3.
isi data
padatabel-tabelberikut :
Tabeljenis_service
Insert
into JENIS_SERVICE values(‘S01’ ,
’Ganti Oli’ , ’25000’);
Insert
into JENIS_SERVICE values(‘S02’ ,
’Service Ringan’ , ’15000’);
Insert
into JENIS_SERVICE values(‘S03’ ,
’Ganti Ban Dalam’ , ’20000’);
Tabelservice_motor
Insert
into SERVICE_MOTOR
values(‘2008-02-19’ , ’AB1001XX’ , ’10012’);
Insert
into SERVICE_MOTOR
values(‘2008-02-19’ , ’B9090JX’ , ’200003’);
Tabeldetail_service
Insert into DETAIL_SERVICE values(‘S01’ , ‘1’);
4.
Ubahtanggal
service menjadi 20/02/2008 untukno_service 2
Update
service_motor set tgl_service = “20/01/2008”
Where
No_service = 2;
5. Ubahno_plat
AD3333G menjadi AA4545CD padatabel motor
Update
motor set NO_PLAT = ‘AD 333G’
Where
No_Plat = ‘AA4545CD’
Select
* from MOTOR
6.
Hapus data motor
denganjenis motor yang mengandung kata ‘mio’
DELETE
FROM MOTOR
WHERE
JENIS LIKE ‘%MIO%’
7.
Buat query
untukmenampilkanmontir yang belumpernahmenservice motor
Select
* from MONTIR Where KDMONTIR
not
in (select KDMONTIR from SERVICE MOTOR)
8.
Buat query
untukmenampilkan no service,jumlahjenis service yang dilakukan
Select
NO_SERVICE , sum(jumlah) as total from
DETAIL_SERVICE
group
by NO_SERVICE
9.
Buat query
untukmenampilkantanggal service danbanyaknya service yang dilakukanperhari
Select
s.TGL_SERVICE , sum(d.jumlah) as SERVICE
from SERVICE_MOTOR s
inner join DETAIL_SERVICE d on
s.NO_SERVICE = d. NO_SERVICE
group by TGL_SERVICE
Labels:
pengetahuan
Thanks for reading CONTOH SCRIPT PERANCANGAN BASIS DATA. Please share...!
0 Comment for "CONTOH SCRIPT PERANCANGAN BASIS DATA"