Created
May 1, 2019 23:03
-
-
Save hqt/75f8ae64fb5b79d09aeea108e6123464 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
DROP PROCEDURE IF EXISTS generate_schema; | |
DELIMITER $$ | |
CREATE PROCEDURE generate_schema() | |
BEGIN | |
DROP TABLE IF EXISTS `foo`; | |
DROP TABLE IF EXISTS `bar`; | |
CREATE TABLE `foo` | |
( | |
`id` INT NOT NULL AUTO_INCREMENT, | |
`name` VARCHAR(255) NOT NULL, | |
`year` INT NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE = InnoDB; | |
CREATE TABLE `bar` | |
( | |
`id` INT NOT NULL AUTO_INCREMENT, | |
`name` VARCHAR(255) NOT NULL, | |
`year` INT NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE = InnoDB; | |
INSERT INTO `foo` (id, name, year) VALUES (1, "stack", 1993); | |
INSERT INTO `foo` (id, name, year) VALUES (2, "over", 1994); | |
INSERT INTO `foo` (id, name, year) VALUES (3, "flow", 1995); | |
INSERT INTO `bar` (id, name, year) VALUES (2, "xyz", 2019); | |
END$$ | |
DELIMITER ; | |
CALL generate_schema(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment