Created
December 8, 2018 20:27
-
-
Save katsube/5fea77a266446033efa17b3a759f46c3 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
/** | |
* モバイルプログラミング2 | |
* SQL実習 | |
* | |
* Date: 2018-12-10 | |
*/ | |
/* ----------------------------------------- */ | |
/* データベース作成 */ | |
/* ----------------------------------------- */ | |
CREATE DATABASE IF NOT EXISTS chat; | |
USE chat; | |
/* ----------------------------------------- */ | |
/* テーブル作成 */ | |
/* ----------------------------------------- */ | |
DROP TABLE IF EXISTS user; | |
CREATE TABLE user( | |
`user_id` varchar(64), | |
`pw` varchar(64), | |
`name` varchar(255), | |
`time` datetime, | |
PRIMARY KEY(`user_id`) | |
); | |
DROP TABLE IF EXISTS log; | |
CREATE TABLE log( | |
`id` integer AUTO_INCREMENT, | |
`user_id` varchar(128), | |
`message` varchar(255), | |
`time` datetime, | |
PRIMARY KEY(`id`) | |
); | |
/* ----------------------------------------- */ | |
/* テストデータ挿入 */ | |
/* ----------------------------------------- */ | |
INSERT INTO user | |
VALUES | |
('foo', 'abc123', 'bar', '2018-12-10 10:00:00'), | |
('banana', 'abc123', 'バナナ', '2018-12-10 11:00:00'), | |
('tarou', 'abc123', '太郎', '2018-12-10 12:00:00') | |
; | |
INSERT INTO log(`user_id`, `message`, `time`) | |
VALUES | |
('banana', 'こんにちは', '2018-12-10 13:00:00'), | |
('tarou', 'Hello!', '2018-12-10 13:00:10'), | |
('tarou', 'Nice to meet you', '2018-12-10 13:00:20'), | |
('tarou', 'Are you OK?', '2018-12-10 13:00:30'), | |
('banana', '日本語でOK', '2018-12-10 13:00:40') | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment