Last active
April 7, 2019 09:58
-
-
Save yuizho/7206b2e75c7b0d719446c64686790abd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run \ | |
-e MYSQL_ROOT_PASSWORD=password \ | |
-e MYSQL_USER=test \ | |
-e MYSQL_PASSWORD=password \ | |
-e MYSQL_DATABASE=test \ | |
-e TZ=Asia/Tokyo \ | |
-p 3306:3306 \ | |
--name mysql_db \ | |
-d mysql:5.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 9章のSQL | |
CREATE DATABASE mydbexample DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; | |
USE mydbexample; | |
CREATE TABLE zaiko | |
(idzai INT NOT NULL AUTO_INCREMENT, | |
product VARCHAR(50) NOT NULL, | |
stock INT NOT NULL DEFAULT 0, | |
PRIMARY KEY (idzai)); | |
CREATE TABLE shukko ( | |
idko INT NOT NULL, | |
taiou INT NOT NULL, | |
outnum INT NOT NULL, | |
outdate DATETIME NOT NULL, | |
PRIMARY KEY (idko), | |
INDEX (taiou) | |
); | |
ALTER TABLE shukko ADD FOREIGN KEY (taiou) REFERENCES zaiko(idzai) ON DELETE RESTRICT ON UPDATE RESTRICT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to use mysql client on docker