抖音点赞粉丝推广运营虚拟服务平台 - 亿抖网欧梦公司

抖音粉丝点赞服务
打通抖音运营之路

mysql增加列字段(详解MySQL新增一列并添加数据)

概述

今天主要分享MySQL数据库列的增删改实现方法,比较基础,大家可以简单看看,也做个备忘!


新建表user_info

CREATE TABLE user_info(
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username CHAR(20) NOT NULL DEFAULT '',
gender TINYINT UNSIGNED NOT NULL DEFAULT 0,
weight TINYINT UNSIGNED NOT NULL DEFAULT 0
)ENGINE=MyISAM DEFAULT CHARSET=utf8;

 

新增列默认在表的最后一列

语法:alter table 表名 add 列名 列类型 列属性

alter table user_info add height tinyint unsigned not null default 0;

 

删除列

语法:alter table 表名 drop 列名

alter table user_info drop height;

 

增加列,放在指定列之后

语法:alter table 表名 add 列名 类型 属性 [默认值] after 指定列名

alter table user_info add height tinyint not null default 0 after username;

 

修改指定列名

语法:alter table 表名 change 旧列名 新列名 类型 属性 默认值

alter table user_info change height shengao smallint not null default 0;

 

modify 修改列,但不能修改列名

语法:alter table 表名 modify 列名 类型 属性 默认值

alter table user_info modify shengao tinyint not null default 0;

 


篇幅有限,这一块内容就介绍到这了,大家啥时候需要对mysql数据库列做增删改操作,看这篇就可以了~

我们的缺点麻烦您能提出,谢谢支持!

联系我们 网站地图