Skip to Main Content
Learn SQL using MySQL in One Day and Learn It Well
book

Learn SQL using MySQL in One Day and Learn It Well

by Jamie Chan
April 2024
Intermediate to advanced content levelIntermediate to advanced
127 pages
2h 29m
English
Packt Publishing
Content preview from Learn SQL using MySQL in One Day and Learn It Well

Chapter 3: Defining Tables

 

In the previous chapter, we learned to create and use a database. In this chapter, we’ll learn to add tables to our database. We’ll also learn to alter and delete the tables if necessary. This is a relatively long chapter, so take your time to slowly go through it.

 

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_name1 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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

MySQL Crash Course

MySQL Crash Course

Rick Silva

Publisher Resources

ISBN: 9781836205678Supplemental Content