What is the ALTER DATABASE statement in MySQL?

The ALTER DATABASE command enables SQL users to change the overall characteristics and structure of any database. These characteristics are stored in the db.opt file in the database directory.

Using ALTER DATABASE

ALTER DATABASE has many features to alter tables in the databases. These include:

  1. Rename table name
  2. Add a column
  3. Change column name
  4. Delete column

For example, the following table, Student_data, contains the fields Name and Age:

Name Age
Ali 19
Michael 21
Jason 20

Rename table name

Change the name of the table from Student_data to College_data:

ALTER TABLE Student_data;
RENAME College_data;

Add a column

We want to add a column that shows the status of every student:

ALTER TABLE College_data;
ADD Status varchar(255);
Name Age Status
Ali 19 NULL
Michael 21 NULL
Jason 20 NULL

Change column name

Change the name of the column Name to Student_Name:

ALTER TABLE College_data;
CHANGE Name Student_Name;
Student_Name Age Status
Ali 19 NULL
Michael 21 NULL
Jason 20 NULL

Delete column

Delete the column Status from our database:

ALTER TABLE College_data;
DROP COLUMN Status;
Name Age
Ali 19
Michael 21
Jason 20

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved