Altering a table


show more Altering a table provides you with in-depth training on Developer. Taught by Bill Weinman as part of the MySQL Essential Training show less
please wait ...

Altering a table

Sometimes, you may need to change the definition of a table after it's already been defined, and populated with data. You can do this with the alter table statement. We're going to be using the scratch database here for this lesson, and I'm just going to copy a little bit of code out of our exercise file. So this is the chapter 3 exercise file starting around line 201. From the create table to the select from test. Just copy that and paste it into the SQL box here.

So we're creating a simple table with 3 columns and populating some data into them and it looks like that. Now suppose some time is passed, and I decide I want a new column. I can use the alter tables statement like this. I'm just going to leave that select statement there and I'm going to say alter table test add d. And I'll make it the same varchar 10. And when I say go, you see we have a new column d, and it's filled with nulls.

The part after the, so we have alter table test, and the part after the add ke...

Altering a table
Video duration: 4m 9s 4h 24m Beginner

Viewers:

Altering a table provides you with in-depth training on Developer. Taught by Bill Weinman as part of the MySQL Essential Training

Subject:
Developer
Software:
MySQL
Author:
please wait ...