mysql> select * from siswa;
mysql> desc guru;
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| no | int(11) | NO | PRI | NULL | auto_increment |
| nama | varchar(15) | YES | | NULL | |
| alamat | text | YES | | NULL | |
+--------+-------------+------+-----+---------+----------------+
3 rows in set (0.02 sec)
mysql> desc siswa;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| nis | int(4) | NO | PRI | NULL | |
| nama | varchar(15) | YES | | NULL | |
| alamat | text | YES | | NULL | |
| no_telp | varchar(12) | YES | | NULL | |
| jenis_kelamin | enum('P','L') | YES | | NULL | |
+---------------+---------------+------+-----+---------+-------+
5 rows in set (0.00 sec)
mysql> create table mapel (
-> id_mapel int auto_increment primary key,
-> kode_mapel varchar(5),
-> mapel varchar(30);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 4
mysql> create table mapel (
-> id_mapel int auto_increment primary key,
-> kode_mapel varchar(5),
-> mapel varchar(30));
Query OK, 0 rows affected (0.03 sec)
mysql> alter table mapel engine=innodb;
Query OK, 0 rows affected (0.19 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> insert into mapel (kode_mapel,mapel)
-> values('BD','bhsindo');
Query OK, 1 row affected (0.03 sec)
mysql> select * from mapel;
+----------+------------+---------+
| id_mapel | kode_mapel | mapel |
+----------+------------+---------+
| 1 | BD | bhsindo |
+----------+------------+---------+
1 row in set (0.00 sec)
mysql> create table mengajar(
-> id_mengajar int auto_increment primary key,
-> no varchar(20),
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 3
mysql> select * from siswa;
+------+------+-------------+--------------+---------------+
| nis | nama | alamat | no_telp | jenis_kelamin |
+------+------+-------------+--------------+---------------+
| 1111 | aan | gemuruh | 089765456342 | L |
| 1112 | afif | tapen | NULL | L |
| 1113 | andi | purwonegoro | NULL | L |
+------+------+-------------+--------------+---------------+
3 rows in set (0.00 sec)
mysql> create table guwru(
-> nip int(10) primary key,
-> nama varchar(20),
-> jenis_kelamin enum('L','P'),
-> alamat text);
Query OK, 0 rows affected (0.05 sec)
mysql> create table mengajar (
-> id_mengajar int auto_increment primary key,
-> nip varchar(20),
-> id_matapelajaran int,
-> foreign key(nip) references guwru(nip)
-> on delete cascade on update cascade,
-> foreign key(id_matapelajaran) references matapelajaran(id_matapelajaran)
-> on delete cascade on update cascade)
-> type=innodb;
ERROR 1005 (HY000): Can't create table 'tkj.mengajar' (errno: 150)
mysql> on delete cascade on update cascade)desc mapel;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'on de
lete cascade on update cascade)desc mapel' at line 1
mysql> show tables;
+---------------+
| Tables_in_tkj |
+---------------+
| guru |
| guwru |
| mapel |
| siswa |
+---------------+
4 rows in set (0.00 sec)
mysql> desc mapel;
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| id_mapel | int(11) | NO | PRI | NULL | auto_increment |
| kode_mapel | varchar(5) | YES | | NULL | |
| mapel | varchar(30) | YES | | NULL | |
+------------+-------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
mysql> create table mengajar (
-> id_mengajar int auto_increment primary key,
-> nip varchar(20),
-> id_matapelajaran int,
-> foreign key(nip) references guwru(nip)
-> on delete cascade on update cascade,
-> foreign key(id_matapelajaran) references matapelajaran(id_matapelajaran)
-> on delete cascade on update cascade);
Query OK, 0 rows affected (0.03 sec)
mysql> show tables;
+---------------+
| Tables_in_tkj |
+---------------+
| guru |
| guwru |
| mapel |
| mengajar |
| siswa |
+---------------+
5 rows in set (0.00 sec)
mysql> drop table mengajar;
Query OK, 0 rows affected (0.01 sec)
mysql> show tables;
+---------------+
| Tables_in_tkj |
+---------------+
| guru |
| guwru |
| mapel |
| siswa |
+---------------+
4 rows in set (0.02 sec)
mysql> create table mengajar (
-> id_mengajar int auto_increment primary key,
-> nip varchar(20),
-> id_matapelajaran int,
-> foreign key(nip) references guwru(nip)
-> on delete cascade on update cascade,
-> foreign key(id_mapel) references mapel(id_mapel)
-> on delete cascade on update cascade)
-> type=innodb;
ERROR 1072 (42000): Key column 'id_mapel' doesn't exist in table
mysql> create table mengajar (
-> id_mengajar int auto_increment primary key,
-> nip varchar(20),
-> id_matapelajaran int,
-> foreign key(nip) references guwru(nip)
-> on delete cascade on update cascade,
-> foreign key(id_matapelajaran) references matapelajaran(id_matapelajaran)
-> on delete cascade on update cascade)
-> type=innodb;
ERROR 1005 (HY000): Can't create table 'tkj.mengajar' (errno: 150)
mysql> create table mengajar (
-> id_mengajar int auto_increment primary key,
-> nip varchar(20),
-> id_matapelajaran int,
-> foreign key(nip) references guwru(nip)
-> on delete cascade on update cascade,
-> foreign key(id_matapelajaran) references matapelajaran(id_matapelajaran);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 7
mysql> show table guwru;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'guwru
' at line 1
mysql> desc guwru;
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| nip | int(10) | NO | PRI | NULL | |
| nama | varchar(20) | YES | | NULL | |
| jenis_kelamin | enum('L','P') | YES | | NULL | |
| alamat | text | YES | | NULL | |
+---------------+---------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> desc mapel;
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| id_mapel | int(11) | NO | PRI | NULL | auto_increment |
| kode_mapel | varchar(5) | YES | | NULL | |
| mapel | varchar(30) | YES | | NULL | |
+------------+-------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
mysql> create table mengajar (
-> id_mengajar int auto_increment primary key,
-> nip int(10),
-> id_mapel int,
-> foreign key(nip) references guwru(nip)
-> on delete cascade on update cascade,
-> foreign key(id_mapel) references mapel(id_mapel)
-> on delete caccade on update cascade)
-> type=innodb;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'cacca
de on update cascade)
type=innodb' at line 8
mysql> create table mengajar (;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
mysql>
mysql> create table mengajar (
-> id_mengajar int auto_increment primary key,
-> nip int(10),
-> id_mapel int,
-> foreign key(nip) references guwru(nip)
-> on delete cascade on update cascade,
-> foreign key(id_mapel) references mapel(id_mapel)
-> on delete cascade on update cascade)
-> type=innodb;
ERROR 1005 (HY000): Can't create table 'tkj.mengajar' (errno: 150)
mysql> create table mengajar
-> id_mengajar int auto_increment primary key,
-> nip int(10),
-> id_mapel int,
-> foreign key(nip) references guwru(nip)
-> on delete cascade on update cascade,
-> foreign key(id_mapel) references mapel(id_mapel)
-> on delete cascade on update cascade
-> type=innodb;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'id_me
ngajar int auto_increment primary key,
nip int(10),
id_mapel int,
foreig' at line 2
mysql> create table mengajar(
-> id_mengajar int auto_increment primary key,
-> nip int(10),
-> id_mapel int(11),
-> foreign key(nip) references guwru(nip)
-> on delete cascade on update cascade,
-> foreign key(id_mapel) references mapel(id_mapel)
-> on delete cascade on update cascade)
-> type=innodb;
ERROR 1005 (HY000): Can't create table 'tkj.mengajar' (errno: 150)
mysql> alter table mapel ENGINE=innodb;
Query OK, 1 row affected (0.13 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> create table mengajar(
-> id_mengajar int auto_increment primary key,
-> nip int(10),
-> id_mapel int(11),
-> foreign key(nip) references guwru(nip)
-> on delete cascade on update cascade,
-> foreign key(id_mapel) references mapel(id_mapel)
-> on delete cascade on update cascade)
-> type=innodb;
ERROR 1005 (HY000): Can't create table 'tkj.mengajar' (errno: 150)
mysql> alter table guwru ENGINE=innodb;
Query OK, 0 rows affected (0.09 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> create table mengajar(
-> id_mengajar int auto_increment primary key,
-> nip int(10),
-> id_mapel int(11),
-> foreign key(nip) references guwru(nip)
-> on delete cascade on update cascade,
-> foreign key(id_mapel) references mapel(id_mapel)
-> on delete cascade on update cascade)
-> type=innodb;
Query OK, 0 rows affected, 1 warning (0.13 sec)
mysql>