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

Basis Data2

The document shows the process of creating a database called db_pustaka and several tables within it using MySQL commands. Tables are created for books, categories, publishers, and authors. Data is then inserted into the books table and selected.

Uploaded by

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

Basis Data2

The document shows the process of creating a database called db_pustaka and several tables within it using MySQL commands. Tables are created for books, categories, publishers, and authors. Data is then inserted into the books table and selected.

Uploaded by

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

Microsoft Windows [Version 10.0.18362.

388]

(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\richa>cp/

'cp' is not recognized as an internal or external command,

operable program or batch file.

C:\Users\richa>cp\

'cp\' is not recognized as an internal or external command,

operable program or batch file.

C:\Users\richa>cd\

C:\>cd bin

The system cannot find the path specified.

C:\>cd bin;

The system cannot find the path specified.

C:\>cd xampp/mysql

C:\xampp\mysql>cd bin;

The system cannot find the path specified.

C:\xampp\mysql>cd bin

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

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 2


Server version: 10.1.16-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database db_pustaka;

Query OK, 1 row affected (0.03 sec)

MariaDB [(none)]> use db_pustaka;

Database changed

MariaDB [db_pustaka]> create table kategori(

-> id_kategori int(10)primary key,

-> nama_kategori varchar(15));

Query OK, 0 rows affected (0.50 sec)

MariaDB [db_pustaka]> create table pengarang(

-> id_pengarang char(3)primary key,

-> nama_pengarang varchar(30));

Query OK, 0 rows affected (0.42 sec)

MariaDB [db_pustaka]> create table penerbit(

-> id_penerbit char(4)primary key,

-> nama_penerbit varchar(50));

Query OK, 0 rows affected (0.34 sec)

MariaDB [db_pustaka]> create table buku(

-> isbn char(13)primary key,

-> judul_buku (100),


-> id_penerbit char(4)primary key,

-> tgl_terbit date,

-> deskripsi text,

-> harga desimal(10,0));

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
MariaDB server version for the right syntax to use near '(100),

id_penerbit char(4)primary key,

tgl_terbit date,

deskripsi text,

harga de' at line 3

MariaDB [db_pustaka]> create table buku(

-> isbn char(13)primary key,

-> judul_buku varchar(100),

-> id_penerbit char(4)primary key,

-> tgl_terbit date,

-> deskripsi text,

-> harga desimal(10,0));

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
MariaDB server version for the right syntax to use near 'desimal(10,0))' at line 7

MariaDB [db_pustaka]> create table buku(

-> isbn char(13)primary key,

-> judul_buku varchar(100),

-> id_penerbit char(4)primary key,

-> tgl_terbit date,

-> deskripsi text,

-> harga decimal(10,0));

ERROR 1068 (42000): Multiple primary key defined

MariaDB [db_pustaka]> create table buku(

-> isbn char(13)primary key,


-> judul_buku varchar(100),

-> id_penerbit char(4),

-> tgl_terbit date,

-> deskripsi text,

-> harga decimal(10,0));

Query OK, 0 rows affected (0.69 sec)

MariaDB [db_pustaka]> show tables;

+----------------------+

| Tables_in_db_pustaka |

+----------------------+

| buku |

| kategori |

| penerbit |

| pengarang |

+----------------------+

4 rows in set (0.13 sec)

MariaDB [db_pustaka]>

MariaDB [db_pustaka]> describe buku;

+-------------+---------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+-------------+---------------+------+-----+---------+-------+

| isbn | char(13) | NO | PRI | NULL | |

| judul_buku | varchar(100) | YES | | NULL | |

| id_penerbit | char(4) | YES | | NULL | |

| tgl_terbit | date | YES | | NULL | |

| deskripsi | text | YES | | NULL | |

| harga | decimal(10,0) | YES | | NULL | |


+-------------+---------------+------+-----+---------+-------+

6 rows in set (0.12 sec)

MariaDB [db_pustaka]> describe kategori;

+---------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+---------------+-------------+------+-----+---------+-------+

| id_kategori | int(10) | NO | PRI | NULL | |

| nama_kategori | varchar(15) | YES | | NULL | |

+---------------+-------------+------+-----+---------+-------+

2 rows in set (0.05 sec)

MariaDB [db_pustaka]> describe penerbit;

+---------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+---------------+-------------+------+-----+---------+-------+

| id_penerbit | char(4) | NO | PRI | NULL | |

| nama_penerbit | varchar(50) | YES | | NULL | |

+---------------+-------------+------+-----+---------+-------+

2 rows in set (0.02 sec)

MariaDB [db_pustaka]> describe pengarang;

+----------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+----------------+-------------+------+-----+---------+-------+

| id_pengarang | char(3) | NO | PRI | NULL | |

| nama_pengarang | varchar(30) | YES | | NULL | |

+----------------+-------------+------+-----+---------+-------+

2 rows in set (0.10 sec)


MariaDB [db_pustaka]> insert into buku values('1','romance','01','1999-05-22','cinta','9000);

'> ;0

'> );

'> sa

'>

'> s

'> d

'> asd

'> as

'> d

'> asd

'> sa

'> d

'> sa

'> d

'> sad

'> sa

'>

'> );

'> Ctrl-C -- exit!

Bye

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

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 3

Server version: 10.1.16-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use db_pustaka;

Database changed

MariaDB [db_pustaka]> insert into buku values('1','romance','01','1999-05-22','cinta','9000');

Query OK, 1 row affected (0.10 sec)

MariaDB [db_pustaka]> insert into buku values('2','comedi','02','2000-04-23','lucu','10000');

Query OK, 1 row affected (0.17 sec)

MariaDB [db_pustaka]> SELECT * FROM buku;

+------+------------+-------------+------------+-----------+-------+

| isbn | judul_buku | id_penerbit | tgl_terbit | deskripsi | harga |

+------+------------+-------------+------------+-----------+-------+

| 1 | romance | 01 | 1999-05-22 | cinta | 9000 |

| 2 | comedi | 02 | 2000-04-23 | lucu | 10000 |

+------+------------+-------------+------------+-----------+-------+

2 rows in set (0.02 sec)

MariaDB [db_pustaka]> insert into buku values('3','Militer','03','2007-08-23','perang','15000');

Query OK, 1 row affected (0.09 sec)

MariaDB [db_pustaka]> SELECT * FROM buku;

+------+------------+-------------+------------+-----------+-------+

| isbn | judul_buku | id_penerbit | tgl_terbit | deskripsi | harga |

+------+------------+-------------+------------+-----------+-------+

| 1 | romance | 01 | 1999-05-22 | cinta | 9000 |

| 2 | comedi | 02 | 2000-04-23 | lucu | 10000 |


| 3 | Militer | 03 | 2007-08-23 | perang | 15000 |

+------+------------+-------------+------------+-----------+-------+

3 rows in set (0.00 sec)

MariaDB [db_pustaka]> describe pengarang;

You might also like