Mysql表结构
2016-01-19 16:57
453 查看
1.查看表
查看表结构命令,如下:desc 表名;
show columns from 表名;
describe 表名;
show create table 表名;
use information_schema
select * from columns where table_name=’表名’;
2.增加列
1.alter table 表名 add 列名 列类型 列参数【加的列在表的最后面】例:alter table test add username char(20) not null default ”;
alter table test add birth date not null default ‘0000-00-00’;
2.alter table 表名 add 列名 列类型 列参数 after 某列【把新列加在某列后面】
例:alter table test add gender char(1) not null default ” after username;
3.alter table 表名 add 列名 列类型 列参数 first【把新列加在最前面】
例:alter table test add pid int not null default 0 first;
3.删除列
alter table 表名 drop 列名例:alter table test drop pid;
4.修改列
1.alter table 表名 modify 列名 新类型 新参数【修改列类型】例:alter table test modify gender char(4) not null default ”;
2.alter table 表名 change 旧列名 新列名 新类型 新参数【修改列名和列类型】
例:alter table test change pid uid int unsigned not null default 0;
相关文章推荐
- mysql恶补_约束1
- MySQL外键的设置及作用
- MySQL存储引擎比较
- MySQL中修改列名或列的数据类型
- mysql也可以查询今天、昨天、7天、近30天、本月、上一月的数据
- MySQL 5.7修改默认密码
- MySQL多表查询之子查询
- [转]mysql免安装版配置
- [转]mysql免安装版配置
- MySQL参考资料
- 数据库---MySQL常用函数总结
- 优化mysql实验(explain;索引)+利用 index、explain和profile优化mysql数据库查询小结
- 编写MYSQL插件(UDF)使其实现Split函数
- [MySQl]MySQL忘记密码
- mysql修改端口经验
- 数据库迁移 - SQLServer->MySQL
- Mysql 如何设置字段自动获取当前时间
- [MySQL]增加用户 授权 远程登录
- ceotos mysql 非法操作恢复
- MySql用DATE_FORMAT截取DateTime字段的日期值