I have even uploaded the .sql file which you can run and directly run them in the sql prompt.
To run sql files
source <filename>.sql;
create database cheatsheet;
use cheatsheet;
show databases;
create table employee ( employee_id int primary key, -- Setting primary key(1st method) first_name varchar(50), last_name varchar(50), dept_number int, age int, salary real ); create table department ( dept_number int, dept_name varchar(50), dept_location varchar(50), emp_id int, primary key(dept_number) -- Setting primary key(2nd method) );
show tables;
describe employee; desc employee; show columns in employee;
rename table employee to employee_table; alter table employee_table rename to employee;
alter table employee change column employee_id emp_id int;
alter table employee change column first_name first_name varchar(50) not null;
alter table employee add column salary real;
alter table employee drop column salary;
alter table employee modify column salary int;
truncate employee;
drop table department;
drop database cheatsheet;