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