>데이터 베이스 >MySQL 튜토리얼 >Mysql数据库修改字段方法总结

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB원래의
2016-06-07 15:53:061968검색

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;

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.