0% found this document useful (0 votes)
11 views

C:/xampp/mysql/bin Mysql - U Root - P Enter Password

The document summarizes the steps taken to create a database called "gaji2014" in MySQL. It shows the creation of two tables - "karyawan" to store employee data and "gaji" to store salary information, linking the two tables with a foreign key constraint. Field structures are defined for both tables.

Uploaded by

Akiki Zakaria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

C:/xampp/mysql/bin Mysql - U Root - P Enter Password

The document summarizes the steps taken to create a database called "gaji2014" in MySQL. It shows the creation of two tables - "karyawan" to store employee data and "gaji" to store salary information, linking the two tables with a foreign key constraint. Field structures are defined for both tables.

Uploaded by

Akiki Zakaria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

C:\xampp\mysql\bin>mysql -u root -p

Enter password:
Welcome to the MySQL monitor. Commands
Your MySQL connection id is 47
Server version: 5.1.41 Source distribut

Type 'help;' or '\h' for help. Type '\c

mysql> create database gaji2014;


Query OK, 1 row affected (0.05 sec)

mysql> usegaji2014;
mysql> show databases;
+--------------------+
| Database

+--------------------+
| information_schema |
| absensi2010
| cdcol

|
|

| dbblog

| dbkmpgrt16
| futsal

|
|

| gaji2014
| mysql
| phpmyadmin

|
|
|

| test

| uploaddnload

+--------------------+
11 rows in set (0.01 sec)

mysql> create table karyawan(nik int(5) primary key,nama


varchar(30),jenkel enum
("L","P"),alamat varchar(50),bagian varchar(20));
Query OK, 0 rows affected (0.01 sec)
K, 0 rows affected (0.01 sec)

mysql> use gaji2014;


Database changed
mysql> show tables;
+--------------------+
| Tables_in_gaji2014 |
+--------------------+
| karyawan

+--------------------+
1 row in set (0.00 sec)

mysql> describe karyawan;


+--------+---------------+------+-----+---------+-------+
| Field | Type

| Null | Key | Default | Extra |

+--------+---------------+------+-----+---------+-------+
| nik

| int(5)

| NO | PRI | NULL

| nama | varchar(30) | YES |


| jenkel | enum('L','P') | YES |

| NULL
| NULL

|
|

|
|

| alamat | varchar(50) | YES |

| NULL

| bagian | varchar(20) | YES |

| NULL

+--------+---------------+------+-----+---------+-------+
5 rows in set (0.03 sec)

mysql> create table gaji(kd_gaji varchar(2)primary key,nik int(5),nama_gaji varc


har(20),besaran int(8),bulan varchar(20),tahun varchar(4),constraint fknik forei
gn key(nik) references karyawan(nik)on update cascade on delete cascade);
Query OK, 0 rows affected (0.01 sec)

mysql> show tables;


+--------------------+
| Tables_in_gaji2014 |
+--------------------+
| gaji

| karyawan

+--------------------+
2 rows in set (0.00 sec)

mysql> describe gaji;


+-----------+-------------+------+-----+---------+-------+
| Field

| Type

| Null | Key | Default | Extra |

+-----------+-------------+------+-----+---------+-------+
| kd_gaji | varchar(2) | NO | PRI | NULL
| nik

| int(5)

| YES | MUL | NULL

| nama_gaji | varchar(20) | YES |


| besaran | int(8)

| YES |

| NULL

| NULL

|
|

| bulan

| varchar(20) | YES |

| NULL

| tahun

| varchar(4) | YES |

| NULL

+-----------+-------------+------+-----+---------+-------+
6 rows in set (0.02 sec)

You might also like