Insert Isi
Table
Setelah belajar membuat table tentunya sekarang perlu belajar
cara mengisikan data ke table atau insert table;
·
Isikan Data Seperti Dibawah :
Isikan data pada Table :
student
NIS
|
Nama
|
Alamat
|
Umur
|
Kelas
|
20170001
|
Aldo Berton
|
Jl. Duri Selatan
|
8
|
K2
|
20170002
|
Angel Christina
|
Jl. Petojo Barat
|
7
|
K1
|
20170003
|
Bella Lorenza
|
Jl. Petojo Bara
|
8
|
K2
|
20170004
|
Charles
|
Jl. Metro Marini Barat
|
7
|
K1
|
20170005
|
Davin
|
Jl. Petojo Utara
|
10
|
K4
|
20170006
|
Donna
|
Jl. Jelambar Jaya
|
10
|
K4
|
20170007
|
Dorothy
|
Jl. Tanah Sereal
|
11
|
K5
|
20170008
|
Dova Ariella
|
Jl. Hanura I
|
12
|
K6
|
20170009
|
Evita
|
Jl. Krendang Raya
|
11
|
K5
|
20170010
|
Grace Florence
|
Jl. Duri Selatan
|
13
|
K6
|
Matakuliah
|
|||
No.
|
Kode
|
Nama
|
SKS
|
1
|
MTK0001
|
Fisika
|
4
|
2
|
MTK0002
|
Kalkulus
|
4
|
3
|
MTK0003
|
Pancasila
|
2
|
4
|
MTK0004
|
Kewarganegaraan
|
2
|
5
|
MTK0005
|
Akuntansi 1
|
3
|
6
|
MTK0006
|
Akuntansi 2
|
3
|
Kode
|
Nama
|
K1
|
Kelas 1
|
K2
|
Kelas 2
|
K3
|
Kelas 3
|
K4
|
Kelas 4
|
K5
|
Kelas 5
|
K6
|
Kelas 6
|
krs
|
||
No
|
nis
|
nama
|
1
|
20170001
|
MTK0001
|
2
|
20170001
|
MTK0002
|
3
|
20170001
|
MTK0003
|
4
|
20170001
|
MTK0004
|
5
|
20170001
|
MTK0005
|
6
|
20170002
|
MTK0001
|
7
|
20170002
|
MTK0002
|
8
|
20170002
|
MTK0003
|
9
|
20170002
|
MTK0004
|
10
|
20170002
|
MTK0005
|
11
|
20170003
|
MTK0001
|
12
|
20170003
|
MTK0002
|
13
|
20170003
|
MTK0003
|
14
|
20170003
|
MTK0004
|
15
|
20170003
|
MTK0005
|
dalam pengisian data dalam tutoril ini diajarkan 2 cara : (
khusus mysql dan sql server ); jika menggunakan primary key maka data tidak
boleh sama key sebagai primary dan untuk foreign key harus ada table linknya .
dan field tidak boleh lebih panjang dari yang dibuat. pengisian table yang ada
linknya dulu.
dalam contoh ini kelas ( kalau ada primary dan foreign key dari
table student )
·
Pengisian cara ini bisa juga untuk oracle
— pengisian table kelas record per record
insert into kelas (kode, nama) values (‘K1’, ‘Kelas 1’);
insert into kelas (kode, nama) values (‘K2’, ‘Kelas 2’);
insert into kelas (kode, nama) values (‘K3’, ‘Kelas 3’);
insert into kelas (kode, nama) values (‘K4’, ‘Kelas 4’);
insert into kelas (kode, nama) values (‘K5’, ‘Kelas 5’);
insert into kelas (kode, nama) values (‘K6’, ‘Kelas 6’);
insert into kelas (kode, nama) values (‘K1’, ‘Kelas 1’);
insert into kelas (kode, nama) values (‘K2’, ‘Kelas 2’);
insert into kelas (kode, nama) values (‘K3’, ‘Kelas 3’);
insert into kelas (kode, nama) values (‘K4’, ‘Kelas 4’);
insert into kelas (kode, nama) values (‘K5’, ‘Kelas 5’);
insert into kelas (kode, nama) values (‘K6’, ‘Kelas 6’);
— pengisian table matakuliah record per record
insert into matakuliah (kode, nama, sks) values (‘MTK0001’, ‘Fisika’, 4);
insert into matakuliah (kode, nama, sks) values (‘MTK0002’, ‘Kalkulus’, 4);
insert into matakuliah (kode, nama, sks) values (‘MTK0003’, ‘Pancasila’, 2);
insert into matakuliah (kode, nama, sks) values (‘MTK0004’, ‘Kewarganegaraan’, 2);
insert into matakuliah (kode, nama, sks) values (‘MTK0005’, ‘Akuntansi 1’, 3);
insert into matakuliah (kode, nama, sks) values (‘MTK0006’, ‘Akuntansi 2’, 3);
insert into matakuliah (kode, nama, sks) values (‘MTK0001’, ‘Fisika’, 4);
insert into matakuliah (kode, nama, sks) values (‘MTK0002’, ‘Kalkulus’, 4);
insert into matakuliah (kode, nama, sks) values (‘MTK0003’, ‘Pancasila’, 2);
insert into matakuliah (kode, nama, sks) values (‘MTK0004’, ‘Kewarganegaraan’, 2);
insert into matakuliah (kode, nama, sks) values (‘MTK0005’, ‘Akuntansi 1’, 3);
insert into matakuliah (kode, nama, sks) values (‘MTK0006’, ‘Akuntansi 2’, 3);
— pengisian table student record per record
insert into student(nis, nama, alamat, umur, kelas) values (‘20170001’, ‘Aldo Berton’, ‘Jl. Duri Selatan’,8, ‘K2’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170002’, ‘Angel Christina’, ‘Jl. Petojo Barat ‘,7, ‘K1’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170003’, ‘Bella Lorenza’, ‘Jl. Petojo Bara’,8, ‘K2’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170004’, ‘Charles’, ‘Jl. Metro Marini Barat’,7, ‘K1’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170005’, ‘Davin’, ‘Jl. Petojo Utara’,10, ‘K4’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170006’, ‘Donna’, ‘Jl. Jelambar Jaya’,10, ‘K4’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170007’, ‘Dorothy’, ‘Jl. Tanah Sereal’,11, ‘K5’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170008’, ‘Dova Ariella’, ‘Jl. Hanura I’,12, ‘K6’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170009’, ‘Evita’, ‘Jl. Krendang Raya’,11, ‘K5’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170010’, ‘Grace Florence’, ‘Jl. Duri Selatan’,13, ‘K6’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170001’, ‘Aldo Berton’, ‘Jl. Duri Selatan’,8, ‘K2’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170002’, ‘Angel Christina’, ‘Jl. Petojo Barat ‘,7, ‘K1’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170003’, ‘Bella Lorenza’, ‘Jl. Petojo Bara’,8, ‘K2’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170004’, ‘Charles’, ‘Jl. Metro Marini Barat’,7, ‘K1’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170005’, ‘Davin’, ‘Jl. Petojo Utara’,10, ‘K4’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170006’, ‘Donna’, ‘Jl. Jelambar Jaya’,10, ‘K4’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170007’, ‘Dorothy’, ‘Jl. Tanah Sereal’,11, ‘K5’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170008’, ‘Dova Ariella’, ‘Jl. Hanura I’,12, ‘K6’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170009’, ‘Evita’, ‘Jl. Krendang Raya’,11, ‘K5’);
insert into student(nis, nama, alamat, umur, kelas) values (‘20170010’, ‘Grace Florence’, ‘Jl. Duri Selatan’,13, ‘K6’);
— pengisian table krs record per record
insert into krs(nis, kode_matakuliah) values (‘20170001’, ‘MTK0001’);
insert into krs(nis, kode_matakuliah) values (‘20170001’, ‘MTK0002’);
insert into krs(nis, kode_matakuliah) values (‘20170001’, ‘MTK0003’);
insert into krs(nis, kode_matakuliah) values (‘20170001’, ‘MTK0004’);
insert into krs(nis, kode_matakuliah) values (‘20170001’, ‘MTK0005’);
insert into krs(nis, kode_matakuliah) values (‘20170002’, ‘MTK0001’);
insert into krs(nis, kode_matakuliah) values (‘20170002’, ‘MTK0002’);
insert into krs(nis, kode_matakuliah) values (‘20170002’, ‘MTK0003’);
insert into krs(nis, kode_matakuliah) values (‘20170002’, ‘MTK0004’);
insert into krs(nis, kode_matakuliah) values (‘20170002’, ‘MTK0005’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0001’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0002’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0003’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0004’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0005’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0006’);
insert into krs(nis, kode_matakuliah) values (‘20170001’, ‘MTK0001’);
insert into krs(nis, kode_matakuliah) values (‘20170001’, ‘MTK0002’);
insert into krs(nis, kode_matakuliah) values (‘20170001’, ‘MTK0003’);
insert into krs(nis, kode_matakuliah) values (‘20170001’, ‘MTK0004’);
insert into krs(nis, kode_matakuliah) values (‘20170001’, ‘MTK0005’);
insert into krs(nis, kode_matakuliah) values (‘20170002’, ‘MTK0001’);
insert into krs(nis, kode_matakuliah) values (‘20170002’, ‘MTK0002’);
insert into krs(nis, kode_matakuliah) values (‘20170002’, ‘MTK0003’);
insert into krs(nis, kode_matakuliah) values (‘20170002’, ‘MTK0004’);
insert into krs(nis, kode_matakuliah) values (‘20170002’, ‘MTK0005’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0001’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0002’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0003’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0004’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0005’);
insert into krs(nis, kode_matakuliah) values (‘20170003’, ‘MTK0006’);
·
Pengisian cara kedua ( langsung semua record )
— pengisian table kelas
insert into kelas (kode, nama) values
(‘K1’, ‘Kelas 1’),
(‘K2’, ‘Kelas 2’),
(‘K3’, ‘Kelas 3’),
(‘K4’, ‘Kelas 4’),
(‘K5’, ‘Kelas 5’),
(‘K6’, ‘Kelas 6’);
insert into kelas (kode, nama) values
(‘K1’, ‘Kelas 1’),
(‘K2’, ‘Kelas 2’),
(‘K3’, ‘Kelas 3’),
(‘K4’, ‘Kelas 4’),
(‘K5’, ‘Kelas 5’),
(‘K6’, ‘Kelas 6’);
— pengisian table matakuliah
insert into matakuliah (kode, nama, sks) values
(‘MTK0001’, ‘Fisika’, 4),
(‘MTK0002’, ‘Kalkulus’, 4),
(‘MTK0003’, ‘Pancasila’, 2),
(‘MTK0004’, ‘Kewarganegaraan’, 2),
(‘MTK0005’, ‘Akuntansi 1’, 3),
(‘MTK0006’, ‘Akuntansi 2’, 3);
insert into matakuliah (kode, nama, sks) values
(‘MTK0001’, ‘Fisika’, 4),
(‘MTK0002’, ‘Kalkulus’, 4),
(‘MTK0003’, ‘Pancasila’, 2),
(‘MTK0004’, ‘Kewarganegaraan’, 2),
(‘MTK0005’, ‘Akuntansi 1’, 3),
(‘MTK0006’, ‘Akuntansi 2’, 3);
— pengisian table student
insert into student(nis, nama, alamat, umur, kelas) values
(‘20170001’, ‘Aldo Berton’, ‘Jl. Duri Selatan’,8, ‘K2’),
(‘20170002’, ‘Angel Christina’, ‘Jl. Petojo Barat ‘,7, ‘K1’),
(‘20170003’, ‘Bella Lorenza’, ‘Jl. Petojo Bara’,8, ‘K2’),
(‘20170004’, ‘Charles’, ‘Jl. Metro Marini Barat’,7, ‘K1’),
(‘20170005’, ‘Davin’, ‘Jl. Petojo Utara’,10, ‘K4’),
(‘20170006’, ‘Donna’, ‘Jl. Jelambar Jaya’,10, ‘K4’),
(‘20170007’, ‘Dorothy’, ‘Jl. Tanah Sereal’,11, ‘K5’),
(‘20170008’, ‘Dova Ariella’, ‘Jl. Hanura I’,12, ‘K6’),
(‘20170009’, ‘Evita’, ‘Jl. Krendang Raya’,11, ‘K5’),
(‘20170010’, ‘Grace Florence’, ‘Jl. Duri Selatan’,13, ‘K6’);
insert into student(nis, nama, alamat, umur, kelas) values
(‘20170001’, ‘Aldo Berton’, ‘Jl. Duri Selatan’,8, ‘K2’),
(‘20170002’, ‘Angel Christina’, ‘Jl. Petojo Barat ‘,7, ‘K1’),
(‘20170003’, ‘Bella Lorenza’, ‘Jl. Petojo Bara’,8, ‘K2’),
(‘20170004’, ‘Charles’, ‘Jl. Metro Marini Barat’,7, ‘K1’),
(‘20170005’, ‘Davin’, ‘Jl. Petojo Utara’,10, ‘K4’),
(‘20170006’, ‘Donna’, ‘Jl. Jelambar Jaya’,10, ‘K4’),
(‘20170007’, ‘Dorothy’, ‘Jl. Tanah Sereal’,11, ‘K5’),
(‘20170008’, ‘Dova Ariella’, ‘Jl. Hanura I’,12, ‘K6’),
(‘20170009’, ‘Evita’, ‘Jl. Krendang Raya’,11, ‘K5’),
(‘20170010’, ‘Grace Florence’, ‘Jl. Duri Selatan’,13, ‘K6’);
— pengisian table krs
insert into krs(nis, kode_matakuliah) values
(‘20170001’, ‘MTK0001’),
(‘20170001’, ‘MTK0002’),
(‘20170001’, ‘MTK0003’),
(‘20170001’, ‘MTK0004’),
(‘20170001’, ‘MTK0005’),
(‘20170002’, ‘MTK0001’),
(‘20170002’, ‘MTK0002’),
(‘20170002’, ‘MTK0003’),
(‘20170002’, ‘MTK0004’),
(‘20170002’, ‘MTK0005’),
(‘20170003’, ‘MTK0001’),
(‘20170003’, ‘MTK0002’),
(‘20170003’, ‘MTK0003’),
(‘20170003’, ‘MTK0004’),
(‘20170003’, ‘MTK0005’);
insert into krs(nis, kode_matakuliah) values
(‘20170001’, ‘MTK0001’),
(‘20170001’, ‘MTK0002’),
(‘20170001’, ‘MTK0003’),
(‘20170001’, ‘MTK0004’),
(‘20170001’, ‘MTK0005’),
(‘20170002’, ‘MTK0001’),
(‘20170002’, ‘MTK0002’),
(‘20170002’, ‘MTK0003’),
(‘20170002’, ‘MTK0004’),
(‘20170002’, ‘MTK0005’),
(‘20170003’, ‘MTK0001’),
(‘20170003’, ‘MTK0002’),
(‘20170003’, ‘MTK0003’),
(‘20170003’, ‘MTK0004’),
(‘20170003’, ‘MTK0005’);