Reader small image

You're reading from  Learn SQL using MySQL in One Day and Learn It Well

Product typeBook
Published inApr 2024
PublisherPackt
ISBN-139781836205678
Edition1st Edition
Right arrow
Author (1)
Jamie Chan
Jamie Chan
author image
Jamie Chan

Jamie Chan is a tutor and freelance programmer with years of experience and a dedicated passion for sharing the joy of programming with as many people as possible. With seven bestselling programming books on Amazon, Jamie's publications stand out for their ability to break down complex concepts into simple terms. Additionally, each book includes complete projects at the end, enabling hands-on learning and a deep understanding of the concepts presented.
Read more about Jamie Chan

Right arrow

Creating Tables

 

First, let’s look at how we can create tables to add to our database. To create a table, we use the following syntax:

 

CREATE TABLE table_name (
      column_name
1 datatype [column constraints],
      
column_name2 datatype [column constraints],
      

      [table constraints],

      [table constraints]

);      

 

Let’s discuss the syntax in detail.

 

Tables in SQL databases are organized in rows and columns. Suppose we want to create a table to store information about the employees of a company. We can design the table as shown below:

 

Image

 

Each column in the table stores a specific piece of information about the employee (such as the id, name and gender of the employee).

 

Each row, on the other hand, stores information about...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learn SQL using MySQL in One Day and Learn It Well
Published in: Apr 2024Publisher: PacktISBN-13: 9781836205678

Author (1)

author image
Jamie Chan

Jamie Chan is a tutor and freelance programmer with years of experience and a dedicated passion for sharing the joy of programming with as many people as possible. With seven bestselling programming books on Amazon, Jamie's publications stand out for their ability to break down complex concepts into simple terms. Additionally, each book includes complete projects at the end, enabling hands-on learning and a deep understanding of the concepts presented.
Read more about Jamie Chan