alter table
语句来修正表中一个字段的数据范例。下面本篇文章就来带人人相识一下alter table语句,引见怎样修正字段范例,愿望对人人有所协助。
在MySQL中,alter table语句是用于在已有的表中增加、修正或删除列(字段)的。
1、增加字段(列)
alter table 表名 add 字段名 数据范例
示例:在表 "Persons" 中增加一个名为 "Birthday" 的新列,数据范例为“date”
alter table Persons add Birthday date
申明:新列 "Birthday" 的范例是 date,能够寄存日期
2、修正字段名
alter table 表名 rename column A to B
3、修正字段范例
alter table 表名 alter column 字段名 数据范例
示例:将表 "Persons" 中的 "Birthday" 列的数据范例改成“year”
alter table Persons alter column Birthday year
申明:"Birthday" 列的数据范例是 year,能够寄存 2 位或 4 位花样的年份。
4、删除字段
alter table 表名 drop column 字段名
示例:删除 "Person" 表中的 "Birthday" 列
alter table Persons drop column Birthday
相干视频教程引荐:《MySQL教程》
以上就是本篇文章的全部内容,愿望能对人人的进修有所协助。更多精彩内容人人能够关注ki4网相干教程栏目!!!
以上就是MySQL怎样修正字段范例?的细致内容,更多请关注ki4网别的相干文章!