Home > Database > Mysql Tutorial > body text

sql alert 修改表或增加列

WBOY
Release: 2016-06-07 17:46:53
Original
3089 people have browsed it

sql 的alert命令是用来修改数据表名,增加列,删除列,修改字段数据类型等.好了下面我们来一个个看实例吧.

数据库ALTER TABLE语法
要添加一列在一个表中,使用下列语法:

ALTER TABLE table_name  ADD column_name datatype
Copy after login
来看个增加例的实例:
Copy after login
<pre class="brush:php;toolbar:false">ALTER TABLE tname  ALTER COLUMN data year
Copy after login
 
Copy after login
这样给tname表加上了一个列为data 类型的year字段
Copy after login
上面是在表中加列的语法下面我们再来看看删除列吧 DROP COLUMN column_name
Copy after login
ALTER TABLE table_name DROP COLUMN column_name
Copy after login
来看个<strong>删除列</strong>实例.
Copy after login
<pre class="brush:php;toolbar:false">ALTER TABLE Persons DROP COLUMN DateOfBirth
Copy after login
再来修改字段类型:
Copy after login
 ALTER COLUMN column_name datatype _id order by w_support desc
Copy after login
P_Id  LastName   FirstName  Address City <br>1       Hansen      Ola        Timoteivn 10 Sandnes <br>2       Svendson    Tove       Borgvn 23 Sandnes <br>3      Pettersen     Kari      Storgt 20 Stavanger
Copy after login
本站整理转载请注明:   
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!