MySQL ALTER TABLE Statement
MySQL ALTER TABLE Statement
In this tutorial, we will learn about MySQL ALTER TABLE Statement. The ALTER TABLE allows us to change an existing table in many ways. For example, We can use this statement to add or remove a column,
change column definitions, add or remove PRIMARY KEY, FOREIGN KEY
constraints, etc.
Syntax
The general syntax of the ALTER TABLE statement is as follows:
mysql> ALTER TABLE <table_name>
<alter option> [{, <alter option>}…]
The can be many alter options like:
ADD COLUMN, ADD CONSTRAINT, ADD INDEX
DROP COLUMN, DROP INDEX , etc.
The common uses of the ALTER TABLE statement are:
- Add or remove a table column.
- Add or remove an index on the table.
- Modify the column in the table.
- Add table constraint
- Reset an AUTO_INCREMENT counter
—
MySQL Tutorials
MySQL Tutorials on this website:
https://www.testingdocs.com/mysql-tutorials-for-beginners/
For more information on MySQL Database: