Snippets

Catalyst2 Create test MyISAM database

Created by Robert last modified
-- The below commands create a basic MySQL/MariaDB database with two tables.
-- Both tables use the MyISAM storage engine. That's not a recommendation;
-- you probably want to use InnoDB instead.

-- Create a database named test
CREATE DATABASE testdb
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;

-- Switch to the new database
USE testdb;

-- Create a table for suppliers
CREATE TABLE suppliers (
  id INT NOT NULL AUTO_INCREMENT,
  name VARCHAR(60) NOT NULL,
  PRIMARY KEY(id)
) ENGINE=MyISAM;

-- Create a table for products
CREATE TABLE products (
  id INT NOT NULL AUTO_INCREMENT,
  supplier INT NOT NULL,
  name VARCHAR(60) NOT NULL,
  PRIMARY KEY(id)
) ENGINE=MyISAM;

-- Insert some suppliers
INSERT INTO suppliers (name) VALUES 
('Wonka Industries'),
('Acme Corp.');

-- Insert some products
INSERT INTO products (supplier, name) VALUES 
(1, 'Wonkies'),
(2, 'Honkies'),
(1, 'Conkies');

Comments (1)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.