当前位置: 首页 > 网络学院 > 服务端脚本教程 > SQL > SQL Alter

SQL
SQL 介绍
SQL Select
SQL Where 子句
SQL Insert
SQL Update
SQL Delete
SQL 技能测试
SQL Order By
SQL 与 & OR
SQL In
SQL Between
SQL Aliases
SQL Join
SQL Union
SQL Create
SQL Drop
SQL Alter
SQL 函数
SQL Group By
SQL Select Into

SQL Alter


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 882 ::
收藏到网摘: n/a

ALTER TABLE
改变表

The ALTER TABLE statement is used to add or drop columns in an existing table.
ALTER TABLE语句可以用来给现有的表进行添加或是删除栏目的操作。

ALTER TABLE table_name 
ADD column_name datatype
ALTER TABLE table_name 
DROP COLUMN column_name

Note: Some database systems don't allow the dropping of a column in a database table (DROP COLUMN column_name).
注意:一些数据库系统不允许删除表中的栏目(DROP COLUMN 栏目名)


Person表:

LastName FirstName Address
Pettersen Kari Storgt 20


Example
举例

To add a column named "City" in the "Person" table:
给这张"Person"表加一个名为"City"的栏目:

ALTER TABLE Person ADD City varchar(30)

Result:
结果:

LastName FirstName Address City
Pettersen Kari Storgt 20  

Example
举例

To drop the "Address" column in the "Person" table:
删除"Person"表中的"Address"栏目

ALTER TABLE Person DROP COLUMN Address

Result:
结果:

LastName FirstName City
Pettersen Kari  

评论 (0) All

登陆 | 还没注册?