1# Creates a Simple User table
2# Uses an auto-incrementing primary key as userId
3
4CREATE TABLE user (
5 userId INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
6 username VARCHAR(100),
7 password VARCHAR(100)
8) ENGINE=InnoDB;
1# Simple table describing a vehicle
2
3CREATE TABLE vehicle(
4 # vehicleId: Unique ID for Primary Key.
5 # This is how we will reference a record
6 vehicleId INT NOT NULL,
7 make VARCHAR(64), # String 64 chars max
8 model VARCHAR(128),
9 derivative VARCHAR(255),
10 PRIMARY KEY(vehicleId)
11);
12
13# Add a record
14INSERT INTO vehicle VALUES(1000,'Volkswagen','Golf','1.5 TSI EVO Match Edition 5dr');
1CREATE TABLE Persons (
2 PersonID int,
3 LastName varchar(255),
4 FirstName varchar(255),
5 Address varchar(255),
6 City varchar(255)
7);
1Creates a new table .
2Example: Creates a new table called ‘users’ in the ‘websitesetup’ database.
3CREATE TABLE users (
4id int,
5first_name varchar(255),
6surname varchar(255),
7address varchar(255),
8contact_number int
9);
1CREATE TABLE table_name (
2
3 column1 datatype,
4
5 column2 datatype,
6
7 column3 datatype,
8
9
10....
11
12);
1CREATE TABLE li_wedding (
2 guest_id INT,
3 last_name VARCHAR(255),
4 first_name VARCHAR(255),
5 attending BOOL,
6 diet VARCHAR(255)
7);
8