• Skip to main content
  • Skip to primary sidebar

Founder at work

Master the skills to create and launch your next SaaS company

  • About Me
  • Reviews
  • Resources
  • Community
  • Contact
  • Lessons
  • Series
  • Search
  • Login

How to create a table and rows in MySQL?

April 7, 2013 by Rick Hernandez Leave a Comment

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;

 

Rick Hernandez

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

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Filed Under: MySQL, Programming

Primary Sidebar

Learn How To Take Your Idea And Convert It Into An App From Scratch Even If You Have Never Written A Single Line Of Code.

  • How to Find Your Next Great App Idea
  • The Secret To Getting PAID To Build Your Own App
  • How To Create Your App (SaaS, Mobile, VR, AR, Game)
  • How To Monetize Your Apps
Learn More
4.82 Ratings

Copyright © 2025 · JSecademy Blog Theme on Genesis Framework · WordPress · Log in