SQL Assingnment
SQL Assingnment
ID - INT autoincrement
last_name - VARCHAR of size 50 should not be null
first_name - VARCHAR of size 50 should not be null
age - INT
job_title - VARCHAR of size 100
date_of_birth - DATE
phone_number - INT
insurance_id - VARCHAR of size 15
Ans:
CREATE TABLE
employees ( ID INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
age INT,
job_title VARCHAR(100),
date_of_birth DATE,
phone_number INT,
nsurance_id VARCHAR(15) );
Q: While inserting the above data, you might get error because of Phone number
column.
-- As phone_number is INT right now. Change the datatype of phone_number to make them
strings of FIXED LENGTH of 10 characters.
-- Do some research on which datatype you need to use for this.
UPDATE employees
SET DOB = ‘1992-06-24’
WHERE first_name = ‘Alex’ AND last_name=’ Thompson’
Create a table called employee_insurance with the following columns and datatypes:
"INS736", "unavailable"
Add a column called email to the employees table. Remember to set an appropriate
datatype
Add the value "unavailable" for all records in email in a SINGLE query
UPDATE employees
SET email = ‘unavailable’ ;