laika222
10/24/2016 - 8:59 PM

Creates table people2, creates column PersonID which cannot be null, and which has a value auto-increment (IN MYSQL), creates first_name col

Creates table people2, creates column PersonID which cannot be null, and which has a value auto-increment (IN MYSQL), creates first_name column as variable length characters with 100 character limit, creates last_name column as variable length characters with 100 character limit, sets PersonID column as the table's Primary Key

CREATE TABLE Persons (
    ID int IDENTITY(1,1) PRIMARY KEY,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int );
    

-- DETAIL!!!

-- Creates table
CREATE TABLE Persons (

-- Sets ID as integer, IDENTITY auto-increments, 1 is the starting number, and the second 1 after the comma makes it so it increments by 1, and Primary Key makes it the Primary Key
    ID int IDENTITY(1,1) PRIMARY KEY,
    
-- Sets LastName as varchar NOT NULL
    LastName varchar(255) NOT NULL,
    
-- Sets FirstName as varchar, allows it to be NULL
    FirstName varchar(255),
    
-- Sets Age as an integer, allows it to be NULL
    Age int );
CREATE TABLE people2 ( 
PersonID INT NOT NULL AUTO_INCREMENT,
first_name VARCHAR (100),
last_name VARCHAR (100),
Primary Key (PersonID)
);

-- DETAIL!!!

-- Creates table people2
CREATE TABLE people2 ( 

-- Creates PersonID column, integer, can't be null, auto-increments
PersonID INT NOT NULL AUTO_INCREMENT,

-- Creates first_name column, varchar, 100 characters
first_name VARCHAR (100),

-- -- Creates last_name column, varchar, 100 characters
last_name VARCHAR (100),

-- Identifies PersonID as the Primary Key
Primary Key (PersonID)
);