Join Bill Weinman for an in-depth discussion in this video Altering a table, part of MySQL Essential Training (2014).
…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 keyword…is really just a normal column definition just like in a create table statement.…
- Writing queries
- Creating and updating databases and tables
- Using MySQL built-in functions
- Sorting and filtering data
- Updating tables with triggers
- Working with subselects and views
- Creating and using a stored function
Skill Level Beginner
1. Installing and Configuring the Test Environment
2. Basic Syntax
3. Creating a Database
4. MySQL Data Types
5. MySQL Functions
8. Subselects and Views
9. Stored Routines
10. PHP's PDO Interface with MySQL
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.