[wd_asp elements=’search’ ratio=’100%’ id=1]

Create database with two tables – .sql file import

29th June 2014

MySql

mysql codehaven category

Just some BASIC MYSQL code that when imported creates a database with two tables and a few fields.

CREATE DATABASE IF NOT EXISTS testcreate DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE testcreate;

DROP TABLE IF EXISTS table1;
CREATE TABLE IF NOT EXISTS table1 (
id int(11) NOT NULL AUTO_INCREMENT,
client varchar(50) NOT NULL,
conversions int(6) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

DROP TABLE IF EXISTS users;
CREATE TABLE IF NOT EXISTS users (
id int(10) NOT NULL AUTO_INCREMENT,
name varchar(20) NOT NULL,
password varchar(20) NOT NULL,
message varchar(1) NOT NULL,
note varchar(200) NOT NULL,
sender varchar(20) NOT NULL,
date datetime NOT NULL,
client_name varchar(50) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;