Sei sulla pagina 1di 3

mysql> Select 10116107 as Ady;

+----------+
| Ady |
+----------+
| 10116107 |
+----------+
1 row in set (0.01 sec)

mysql> select now() AS "Waktu mulai";


+---------------------+
| Waktu mulai |
+---------------------+
| 2018-04-24 08:39:12 |
+---------------------+
1 row in set (0.00 sec)

mysql> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| 10116107_nilai |
| cok |
| mysql |
| performance_schema |
| test |
+--------------------+
6 rows in set (0.00 sec)

mysql> create database 10116107_supermarket;


Query OK, 1 row affected (0.00 sec)

mysql> create table barang(


-> kd_barang char(4) not null,
-> varchar(20) not null,;
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
'varchar(20) not null,' at line 3
mysql> create table barang(
-> kd_barang char(4) not null default "",
-> nama varchar(20) not null default "",
-> harga int(11) not null default "",
-> stok int(11) not null default "",
-> expire_date date not null default "",
-> primary key(kd_barang)
-> ) engine=innodb;
ERROR 1067 (42000): Invalid default value for 'harga'
mysql> create table barang(
-> kd_barang char(4) not null default "",
-> nama varchar(20) not null default "",
-> harga int(11) not null default="",
-> stok int(11) not null default="",
-> expire_date date not null default="",
-> primary key(kd_barang)
-> ) engine=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 '="",
stok int(11) not null default="",
expire_date date not null default="",
pri' at line 4
mysql> create table barang(
-> kd_barang char(4) not null,
-> nama varchar(20) not null,
-> harga int(11) not null,
-> stok int(11) not null,
-> expire_date date not null,
-> primary key(kd_barang)
-> ) engine=innodb;
Query OK, 0 rows affected (0.18 sec)

mysql> create table pegawai(


-> kd_pegawai varchar(20) not null,
-> nama varchar(20) not null,
-> alamat varchar(30) not null,
-> jenis_kelamin enum('L','P'),
-> telp varchar(15) not null,
-> primary key(kd_barang)
-> ) engine=innodb;
ERROR 1072 (42000): Key column 'kd_barang' doesn't exist in table
mysql> create table pegawai(
-> kd_pegawai char(4) not null,
-> nama varchar(20) not null,
-> alamat varchar(30) not null,
-> jenis_kelamin enum('L','P') not null,
-> telp varchar(15) not null,
-> primary key(kd_pegawai)
-> ) engine=innodb;
Query OK, 0 rows affected (0.17 sec)

mysql> create table transaksi(


-> id_transaksi int(11) not null auto_increment,
-> kd_barang char(4) not null,
-> kd_pegawai char(4) not null,
-> qty int(11) not null,
-> harga int(11) not null,
-> total int(11) not null,
-> foreign key (kd_barang) references barang(kd_barng) on delete cascade on
update cascade,
-> foreign key (kd_pegawai) references barang(kd_pegawai) on delete cascade on
update cascade,
-> primary key(id_transaksi)
-> )engine=innodb;
ERROR 1215 (HY000): Cannot add foreign key constraint
mysql> create table transaksi(
-> id_transaksi int(11) not null auto_increment,
-> kd_barang char(4) not null,
-> kd_pegawai char(4) not null,
-> qty int(11) not null,
-> harga int(11) not null,
-> total int(11) not null,
-> foreign key (kd_barang) references barang(kd_barang) on delete cascade on
update cascade,
-> foreign key (kd_pegawai) references barang(kd_pegawai) on delete cascade on
update cascade,
-> primary key(id_transaksi)
-> )engine=innodb;
ERROR 1215 (HY000): Cannot add foreign key constraint
mysql> create table transaksi(
-> id_transaksi int(11) not null auto_increment,
-> kd_barang char(4) not null,
-> kd_pegawai char(4) not null,
-> qty int(11) not null,
-> harga int(11) not null,
-> total int(11) not null,
-> foreign key (kd_barang) references barang(kd_barang) on delete cascade on
update cascade,
-> foreign key (kd_pegawai) references pegawai(kd_pegawai) on delete cascade on
update cascade,
-> primary key(id_transaksi)
-> )engine=innodb;
Query OK, 0 rows affected (0.24 sec)

mysql> desc transaksi;


+--------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+---------+------+-----+---------+----------------+
| id_transaksi | int(11) | NO | PRI | NULL | auto_increment |
| kd_barang | char(4) | NO | MUL | NULL | |
| kd_pegawai | char(4) | NO | MUL | NULL | |
| qty | int(11) | NO | | NULL | |
| harga | int(11) | NO | | NULL | |
| total | int(11) | NO | | NULL | |
+--------------+---------+------+-----+---------+----------------+
6 rows in set (0.00 sec)

mysql> show tables;


+--------------------------+
| Tables_in_10116107_nilai |
+--------------------------+
| barang |
| kuliah |
| mahasiswa |
| nilai |
| pegawai |
| transaksi |
+--------------------------+
6 rows in set (0.00 sec)

mysql> notee

Potrebbero piacerti anche