You are on page 1of 3

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

Your MariaDB connection id is 10


Server version: 10.1.34-MariaDB mariadb.org binary distribution

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

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

MariaDB [(none)]> create database MovieIndustry031;


Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> Show databases;


+--------------------+
| Database |
+--------------------+
| ajc |
| db_pegawai |
| information_schema |
| movieindustry031 |
| mysql |
| performance_schema |
| phpmyadmin |
| renko |
| test |
| tugas_renko |
| university |
+--------------------+
11 rows in set (0.00 sec)

MariaDB [(none)]> Use MovieIndsutry031;


ERROR 1049 (42000): Unknown database 'movieindsutry031'
MariaDB [(none)]> Use MovieIndustry031;
Database changed
MariaDB [MovieIndustry031]> create table Studio(
-> name varchar (30) not null primary key,
-> address varchar (50) not null,
-> pres varchar (30) not null);
Query OK, 0 rows affected (0.88 sec)

MariaDB [MovieIndustry031]> show tables;


+----------------------------+
| Tables_in_movieindustry031 |
+----------------------------+
| studio |
+----------------------------+
1 row in set (0.00 sec)

MariaDB [MovieIndustry031]> desc studio;


+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| name | varchar(30) | NO | PRI | NULL | |
| address | varchar(50) | NO | | NULL | |
| pres | varchar(30) | NO | | NULL | |
+---------+-------------+------+-----+---------+-------+
3 rows in set (0.02 sec)

MariaDB [MovieIndustry031]> create table Movie(


-> title varchar (30) not null,
-> year numeric (4) not null,
-> length numeric (3) not null,
-> inColor char (1) not null,
-> studioName varchar (30) not null,
-> primary key (title,year));
Query OK, 0 rows affected (0.25 sec)

MariaDB [MovieIndustry031]> show tables;


+----------------------------+
| Tables_in_movieindustry031 |
+----------------------------+
| movie |
| studio |
+----------------------------+
2 rows in set (0.00 sec)

MariaDB [MovieIndustry031]> desc Movie;


+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| title | varchar(30) | NO | PRI | NULL | |
| year | decimal(4,0) | NO | PRI | NULL | |
| length | decimal(3,0) | NO | | NULL | |
| inColor | char(1) | NO | | NULL | |
| studioName | varchar(30) | NO | | NULL | |
+------------+--------------+------+-----+---------+-------+
5 rows in set (0.02 sec)

MariaDB [MovieIndustry031]> Create table MovieStar(


-> name varchar (30) not null primary key,
-> birthPlace varchar (50) not null,
-> birthDate date not null,
-> gender char (1) not null);
Query OK, 0 rows affected (2.10 sec)

MariaDB [MovieIndustry031]> show tables;


+----------------------------+
| Tables_in_movieindustry031 |
+----------------------------+
| movie |
| moviestar |
| studio |
+----------------------------+
3 rows in set (0.00 sec)

MariaDB [MovieIndustry031]> desc MovieStar;


+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| name | varchar(30) | NO | PRI | NULL | |
| birthPlace | varchar(50) | NO | | NULL | |
| birthDate | date | NO | | NULL | |
| gender | char(1) | NO | | NULL | |
+------------+-------------+------+-----+---------+-------+
4 rows in set (0.02 sec)

MariaDB [MovieIndustry031]> Create table StarsIn(


-> movieTitle varchar (50) not null,
-> movieYear numeric (4) not null);
Query OK, 0 rows affected (4.31 sec)

MariaDB [MovieIndustry031]> show tables;


+----------------------------+
| Tables_in_movieindustry031 |
+----------------------------+
| movie |
| moviestar |
| starsin |
| studio |
+----------------------------+
4 rows in set (0.00 sec)

MariaDB [MovieIndustry031]> desc starsin;


+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| movieTitle | varchar(50) | NO | | NULL | |
| movieYear | decimal(4,0) | NO | | NULL | |
+------------+--------------+------+-----+---------+-------+
2 rows in set (0.02 sec)

MariaDB [MovieIndustry031]> alter table StarsIn


-> add foreign key (movieTitle) references Movie(title);
Query OK, 0 rows affected (0.66 sec)
Records: 0 Duplicates: 0 Warnings: 0

You might also like