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 table_name
2(
3column1 TYPE [COLUMN CONSTRAINTS],
4column2 TYPE [COLUMN CONSTRAINTS],
5column3 TYPE [COLUMN CONSTRAINTS],
6[TABLE CONSTRAINTS...]
7);
1CREATE TABLE table_name(
2 id INT AUTO_INCREMENT PRIMARY KEY,
3 name VARCHAR(255), # String 255 chars max
4 date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
5 longtext BLOB
6);
1//to create a table
2CREATE TABLE students
3( student_id number(4) primary key,
4 last_name varchar2(30) NOT NULL,
5 course_id number(4) NULL );
6
7//to insert value
8INSERT INTO students VALUES (200, 'Jones', 101);
9INSERT INTO students VALUES (201, 'Smith', 101);
10INSERT INTO students VALUE (202, 'Lee' , 102);
1
2CREATE TABLE Persons
3(
4PersonID int,
5LastName varchar(255),
6FirstName varchar(255),
7Address varchar(255),
8City varchar(255)
9);
10