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

Altering Tables

 

We’ve covered quite a bit in this chapter so far. To recap, we learned that to create a table, we need to do two things:

 

1) Specify the columns by stating their names, data types and constraints (if any)
2) Specify any table constraints that the table must fulfil

 

Now that we have created the two tables that we need, let’s move on to learn how we can modify tables. This is useful if we need to make any changes to our tables after creating them.

 

Table Names

 

The first thing we can modify is the table name. To do that, we use the syntax

 

RENAME TABLE old_name TO new_name;

 

Let’s change the name of our co_employees table to employees now. To do that, execute the following statement:

 

RENAME TABLE co_employees TO employees;

 

Columns and Table Constraints

 

Next, let’s learn to alter some of the columns and table constraints of our tables. For each of the alterations...

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