本文实例讲述了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相关内容感兴趣的读者可查看本站专题:《MySQL常用函数大汇总》、《MySQL日志操作技巧大全》、《MySQL事务操作技巧汇总》、《MySQL存储过程技巧大全》及《MySQL数据库锁相关技巧汇总》
希望本文所述对大家MySQL数据库计有所帮助。
标签:
MySQL,数据库,列,增删改
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无争山庄资源网 Copyright www.whwtcm.com
暂无“MySQL数据库列的增删改实现方法”评论...
更新日志
2024年09月27日
2024年09月27日
- 人听人爱,入耳即溶《天碟落地3《HIFI瑰宝》示范颠峰之作》[WAV+CUE/分轨][839.9MB]
- 莫扎特安魂曲舍尔琴,维也纳国家歌剧院,1958【FLAC】
- 罗西尼五部歌剧序曲班贝格佩雷亚1958年【FLAC】
- 【HIRES】李云迪-莫扎特:钢琴奏鸣曲计划-萨尔兹堡-2024-24-96FLAC分轨
- 珍娜JheenaLodwick-GettingToKnowYou(XRCD)[WAV+CUE]
- 珍纳JheenaLodwick-AllMyLoving全我所爱(XRCD)[WAV+CUE]
- JheenaLodwick-Feeling挚爱(XRCD)[WAV+CUE]
- 人听人爱,入耳即溶《天碟落地2《测机王HQ》日本母带发烧音质》[WAV+CUE/分轨][709.9MB]
- 人听人爱,入耳即溶《天碟落地1《示范碟皇》殿堂级演绎名作》[WAV+CUE/分轨][786.9MB]
- MICO刘为《观·自在行》CD[FLAC/分轨][1.3GB]
- 珍纳JheenaLodwick-SingingInTheRain(XRCD)[WAV+CUE]
- 珍纳JheenaLodwick-Feelings非常感觉2-HDCD[WAV+CUE]
- 珍纳精选JheenaLodwick-JheenaLodwickGreatest[香港版]2015[WAV+CUE]
- 谁杀死了HI-FI音乐-《涂鸦精选VOL.2》[WAV+CUE]
- Mav-Mav《美芙的祈祷》(2000)[WAV+CUE]