Beamtic's logo
  1. Create user

Share via:

SQL: Alter Table

How to use the alter table SQL statement to modify existing database tables.


Edited: 2020-07-25 01:12

Alter table, SQL

The alter table statement is used to change the composition of a table; a common usage is to change column names and data types, but it also allows adding and dropping columns to a table.

The below query will change the datatype of the test column in the my_test_table table:

alter table my_test_table modify column test varchar(200);

Adding and removing columns

To add a new column to an existing table:

alter table my_table_name add name_of_new_column varchar(255);

To remove a column from an existing table:

alter table my_table_name drop column name_of_column;

Changing the datatype or the length of a column

Sometimes we might need to change the datatype or length of an existing column, to do that we should use the modify column statement:

alter table my_test_table modify column test varchar(200);

We should carefully choose a datatype and length that suits the needs of our application.

Note. The maximum size of a varchar column is 65.535 characters.


  1. In-app browsers do some things a little differently than normal browsers, and that might result in 500 errors on your server, among other interesting things.
  2. Short explanation of the HTTP range header.
  3. Learn why 403 is the most suitable status code for failed log in attempts.
  4. How to block unused URL parameters (non-existent) in PHP web applications.
  5. Tutorial on Absolute and Relative Paths in Windows, UNIX and the Web.

More in: Web development