ALTER TABLE statement
The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
SQL ALTER TABLE syntax
To add columns to the table, please use the following syntax:
ADD column_name datatype
To delete a column in a table, use the following syntax (please note that some database systems do not allow this method of deleting columns in a database table):
DROP COLUMN column_name
To change the data type of a column in a table, use the following syntax:
SQL Server/MS Access:
ALTER COLUMN column_name datatype
My SQL/Oracle:
MODIFY COLUMN column_name datatype
##SQL ALTER TABLE examplePlease see the "Persons" table:
| LastName | FirstName | Address | City | |
|---|---|---|---|---|
| Hansen | Ola | Timoteivn 10 | Sandnes | |
| Svendson | Tove | Borgvn 23 | Sandnes | |
| Pettersen | Kari | Storgt 20 | Stavanger |
Data Types Reference.
Now, the "Persons" table will look like this:| LastName | FirstName | Address | City | DateOfBirth | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Hansen | Ola | Timoteivn 10 | Sandnes | ||||||||||||||||||||||
| Tove | Borgvn 23 | Sandnes | ##3 | ||||||||||||||||||||||
| Kari | Storgt 20 | Stavanger | Change Data Type ExampleNow, we want to change the data type of the "DateOfBirth" column in the "Persons" table. We use the following SQL statement: ALTER TABLE Persons ALTER COLUMN DateOfBirth year Please note that now the "DateOfBirth" column The type is year, which can store the year in 2-digit or 4-digit format. DROP COLUMN ExampleNext, we want to delete the "DateOfBirth" column in the "Person" table. We use the following SQL statement: ALTER TABLE Persons DROP COLUMN DateOfBirth Now, the "Persons" table will look like this :
Hot AI Tools
Undress AI Tool
Undress images for free
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undresser.AI Undress
AI-powered app for creating realistic nude photos
ArtGPT
AI image generator for creative art from text prompts.
Stock Market GPT
AI powered investment research for smarter decisions
Hot Article
How to fix a monitor's color looking washed out or yellow?
1 months ago By 下次还敢
Cyberpunk 2077 Officially Returns In 2026 With A New Kind Of Game
1 months ago By Jack chen
Windows10 cannot connect to the Internet_Win10 network reset command detailed explanation
2 weeks ago By DDD
How to add subtitles in premiere
4 weeks ago By 下次还敢
Hot Topics
# Douyin level price list 1-75
20461
7
# wifi shows no ip assigned
13602
4
Popular tool
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3) |












![Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]](https://img.php.cn/upload/course/000/000/035/5d27fb58823dc974.jpg)









