Creating tables in MySQL is a piece of cake since we got are database rolling now, its time to get some tables going. In this example 3 tables will be created, SuperSalesPerson, FancyOrders, BestCustomers. This three tables will hold different types of data and hold different types of rows. In the SuperSalesPerson there will be a Name and it will be stored as a varChar (15), age int, and salary which will also be an int, then next is thing will be our FancyOrders which will have Number int, CustomerName varchar (25), and amount will be int, and finally it will be Customer, with a name varchar (25) of course then City varchar(15), and last but not least IndustryType char(1).
SuperSalesPerson
CREATE TABLE SuperSalesPerson ( name varchar(15), age int, salary int );
FancyOrders
CREATE TABLE FancyOrders ( Number int, CustomerName varchar(25), SuperSalesPerson varchar(15), Amount int );
BestCustomers
create table BestCustomers ( name varchar(25), City varchar(15), IndustryType char(1) );
As you can see its simple and straight forward. Somethings to consider when creating a table columns are also being created that’s what goes insides the brackets of the statement of CREATE TABLE if not knowing what the rows are going to be holding its always best practice to model the data as close as possible to what is being represented for example my SuperSalesPerson has a name which is a varchar, hi/she has an age, and a salary. The data is creating the rows or tuples (rows) in the table.
Just like databases tables can also be dropped (deleted) and shown the same way a database is deleted. for example:
DROP TABLE NameOfTable; SHOW TABLES;
I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More