Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learn SQL using MySQL in One Day and Learn It Well

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

Product type Book
Published in Apr 2024
Publisher Packt
ISBN-13 9781836205678
Pages 121 pages
Edition 1st Edition
Languages
Author (1):
Jamie Chan Jamie Chan
Profile icon Jamie Chan

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 chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}