Skip to content

Instantly share code, notes, and snippets.

@thomd
Last active December 13, 2022 14:35
Show Gist options
  • Save thomd/38917fe1f3353b648fc47fc8bd30a157 to your computer and use it in GitHub Desktop.
Save thomd/38917fe1f3353b648fc47fc8bd30a157 to your computer and use it in GitHub Desktop.
create a test database for learning sql #sql
CREATE DATABASE IF NOT EXISTS test;
USE test;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
c1 BIGINT(20) NOT NULL,
c2 tinytext NOT NULL,
c3 tinytext NOT NULL,
c4 DATE NOT NULL,
KEY c1 (c1)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES
(1, 'foo1', 'bar1', '2017-05-01'),
(2, 'foo2', 'bar2', '2018-01-01'),
(3, 'foo3', 'bar3', '2015-02-01'),
(4, 'foo4', 'bar4', '2020-03-01');
UNLOCK TABLES;
DROP TABLE IF EXISTS t2;
CREATE TABLE t2 (
c1 BIGINT(20) NOT NULL,
c2 tinytext NOT NULL,
c3 DECIMAL(10,2) NOT NULL,
c4 BIGINT(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
LOCK TABLES t2 WRITE;
INSERT INTO t2 VALUES
(1, 'baz', 49.95, 1),
(2, 'baz', 59.90, NULL),
(3, 'goo', 79.95, 2),
(4, 'baz', 59.90, 3),
(5, 'goo', 29.99, 4),
(6, 'goo', 99.99, NULL),
(7, 'goo', 29.99, NULL);
UNLOCK TABLES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment