The ALTER Operation
The ALTER
keyword is used to make changes to the schemas present in the database. For example, if we want to add or delete columns in a table, we should be using ALTER
. It can also be used rename to tables. For example:
ALTER TABLE departmentdemo RENAME TO departmentcopy;
This will rename the table departmentdemo
to departmentcopy
.
Now, let us look at solving one of the main issues we might encounter with auto-increment values using alter
.
Exercise 2.04: Manipulating the Auto-Increment Values in a Table
In this exercise, we'll alter a table and manipulate the auto-increment values. We'll be continuing from where we left off in Exercise 2.03, Specifying Default Values. Let's go through the following steps:
- Delete the rows where
departmentNo
is greater than 2; this will delete the two rows wheredepartmentNo
is 3 and 4:delete from department where departmentNo>2;
- Select the
department
table to get a preview of the existing...