Home > Database > Mysql Tutorial > Mysql数据库修改字段方法总结

Mysql数据库修改字段方法总结

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:53:06
Original
1991 people have browsed it

Mysql数据库修改字段方法总结 1添加表字段 alter table student add sex varchar(2) not null; alter table student add id int unsigned not null auto_increment primary key 2.修改某个表的字段类型及指定为空或非空 alter table 表名称 modify 字段名称

Mysql数据库修改字段方法总结

1添加表字段

alter table student add sex varchar(2) not null;


alter table student add id int unsigned not null auto_increment primary key


2.修改某个表的字段类型及指定为空或非空

alter table 表名称 modify 字段名称 字段类型 [是否允许非空 not null / null];


eg: alter table student modify name varchar(20) null


3.修改某个表的字段名称及指定为空或非空

alter table 表名称 change 字段原名称 字段新名称 字段类型 [是否允许非空not null / null]


eg: alter table student change sex xingbie varchar(3) not null;


4如果要删除某一字段,可用命令:

alter table 表名称 drop 字段名称;


eg: alter table student drop xingbie;

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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template