Alterations
In this lesson we discuss how to modify various database structures once they are created.
We'll cover the following...
We'll cover the following...
Alterations
MySQL allows us to change our mind about the entities we create and alter them. We can rename tables, add, remove, or rename columns, change type of an existing column, etc.
Example Syntax
ALTER TABLE table
CHANGE oldColumnName newColumnName <datatype> <restrictions>;
Connect to the terminal below by clicking in the widget. Once connected, the command line prompt will show up. Enter or copy and paste the command ./DataJek/Lessons/17lesson.sh and wait for the MySQL prompt to start-up.
-
Let’s say we want to rename the column FirstName to First_Name for the Actors table. We can do so as follows:
ALTER TABLE Actors CHANGE FirstName First_Name varchar(120);