Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.06 KB

DB.md

File metadata and controls

52 lines (38 loc) · 1.06 KB

DB

Params

  • username: "root",
  • password: "FILL_THIS",
  • database: "elixir",
  • hostname: "172.60.1.13",

Log into the container

docker exec -it elixir-mysql bash

Log into the mysql service

mysql -uroot -p

Create a DB

CREATE DATABASE `elixir`;

Create tables

USE `elixir`;

CREATE TABLE `user`(
    `id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'MAX 65535 records',
    `name` VARCHAR(250) NOT NULL,
    `surname` VARCHAR(250) NOT NULL,
    PRIMARY KEY(`id`)
) ENGINE = INNODB DEFAULT CHARACTER SET = UTF8;

INSERT INTO `user` (`name`, `surname`) VALUES('John', 'Doe'),('Jane', 'Doe');

SELECT * FROM `user`;

CREATE TABLE `post`(
    `id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'MAX 65535 records',
    `title` VARCHAR(250) NOT NULL,
    `user_id` SMALLINT UNSIGNED NULL DEFAULT NULL COMMENT 'Author who created this post.',
    PRIMARY KEY(`id`)
) ENGINE = INNODB DEFAULT CHARACTER SET = UTF8;

INSERT INTO `post` (`title`, `user_id`) VALUES('post A', 1),('post B', 1);

SELECT * FROM `post`;