Anda di halaman 1dari 3

D:

d:xampp\mysql\bin\mysql.exe -u root -p

create database db_kampusbsi;

use db_kampusbsi;

show databases;

create table mahasiswa(nim char(10)primary key, nama varchar(15), alamat varchar(10));

create table mata_kuliah(KD_MK char(6)primary key, nama_MK varchar(20), sks varchar(5));

create table nilai(nim char(10)primary key, KD_MK varchar(6), mid varchar(5), final varchar(5));

show tables;

insert into mahasiswa values('10296832','Nurhayati','Jakarta');

insert into mahasiswa values('10296126','Astuti','Jakarta');

insert into mahasiswa values('31296500','Budi','Depok');

insert into mahasiswa values('41296525','Prananigrum','Bogor');

insert into mahasiswa values('50096487','Pipit','Bekasi');

insert into mahasiswa values('21196353','Quraish','Bogor');

insert into mahasiswa values('10296001','Fintri','Depok');

insert into mahasiswa values('21198002','Julizar','Jakarta');

insert into mahasiswa values('12180213','Noviyanti','Bogor');

insert into mata_kuliah values('KK021','Sistem Basis Data','2');

insert into mata_kuliah values('KD132','Sistem Informasi Manajemen','3');

insert into mata_kuliah values('KU122','Pancasila','2');

insert into nilai values('10296832','KK021','60','75');

insert into nilai values('10296126','KD132','70','90');

insert into nilai values('31296500','KK021','55','40');

insert into nilai values('41296525','KU122','90','80');

insert into nilai values('50096487','KD132','80','0');

insert into nilai values('21196353','KK021','85','60');

insert into nilai values('10296001','KD132','75','65');

insert into nilai values('21198002','KU122','83','90');


insert into nilai values('12180213','KK021','86','95');

desc mahasiswa;

desc mata_kuliah;

desc nilai;

select * from mahasiswa;

select * from mata_kuliah;

select * from nilai;

select * from mahasiswa where alamat='Jakarta';

select * from nilai where MID >=75 or final <100;

select * from mahasiswa;

update mahasiswa set alamat='Depok' where nim='10296832';

select * from mahasiswa;

delete from mahasiswa where nim='50096487';

select * from mahasiswa;

select * from mahasiswa where nama like '%ti';

select nim, nama, alamat from mahasiswa where alamat!='Depok';

select * from mahasiswa where alamat='Bogor' order by nim asc;

alter table mahasiswa change nama nama_mahasiswa varchar(20);

desc mahasiswa;

select * from mahasiswa;

alter table nilai change KD_MK kode_MK varchar(6);

select *from nilai;

alter table mata_kuliah change KD_MK kode_MK varchar(6);

select * from mata_kuliah;

drop table nilai;

show tables;

select nilai.nim, mahasiswa.nama_mahasiswa, nilai.KD_MK, nilai.mid from nilai inner join mahasiswa
on nilai.nim=mahasiswa.nim;
select mahasiswa.nim, mahasiswa.nama_mahasiswa, nilai.KD_MK, nilai.mid from mahasiswa left
outer join nilai on nilai.nim=mahasiswa.nim;

select mahasiswa.nim, mahasiswa.nama_mahasiswa, nilai.KD_MK, nilai.mid from nilai right outer


join mahasiswa on nilai.nim=mahasiswa.nim;