常用操作指令
  1. show databases;显示所有的数据库;
  2. use dbName; 使用指定数据库
  3. show tables; 显示所有的数据表;
  4. desc tableName; 查看数据表的字段信息;
  5. show create table tableName; 查询创建表的所有信息;
  6. show create database dbName; 查看数据库创建指令;
  7. show full processlist; 查看所有进程
  8. drop table tableName; 删除表
  9. alter table tableName add constraint 主键(如:PK_TableName) primary key  tableName(主键字段);添加主键约束
  10. alter table tableName add constraint 从表 (如:FK_从表_主表) foreign key 从表(外键字段) references 主表(主键字段) ;添加外键约束
  11. alter table tableName add constraint 唯一约束 (如:uk_t_1) unique(字段名); 添加唯一约束;
  12. alter table tableName drop primary key; 删除主键约束
  13. alter table tableName drop foreign key 外键(区分大小写);删除外键约束
  14. mysqldump -uroot -pXXXX -h19.168.5.2 -P30118 --databases mgmt >/tmp/mgmt.sql: 导出指定数据库

创建数据库:
  1. create database if not exists `myTestDB`;
 

创建数据表:
  1. create table if not exists `t_user`(
  2. `userid` int(11) not null auto_increment,
  3. `userName` varchar(32) not null DEFAULT '',
  4. `password` varchar(32) DEFAULT null,
  5. `createTime` timestamp not null DEFAULT CURRENT_TIMESTAMP,
  6. `status` smallint(4) default null,
  7. `lastLoginTime` datetime DEFAULT null,
  8. primary key (`userid`),
  9. UNIQUE key `userName`(`userName`)
  10. )ENGINE=InnoDB auto_increment=3 default CHARSET=utf8;


插入数据
 
在指定的列中插入数据
  1. insert into t_user(userName,password,createTime,status,lastLoginTime) values("Tom","12345","2016-12-12 13:45:12",1,"2016-12-12 13:45:12");
  2. insert into t_user(userName,password,createTime,status,lastLoginTime) values("Lily","12345","2016-12-12 14:45:12",1,"2016-12-12 14:45:12");
  3. insert into t_user(userName,password,status,lastLoginTime) values("Jenny","12345",1,"2016-12-12 14:45:12");

 
 
 

最新文章

  1. bmp图片的有关操作
  2. iOS开发随笔
  3. Visual Studio示例代码浏览器
  4. linux&win7双系统安装
  5. 关于TouchEvent里面的touches,targetTouches,changedTouches的解释
  6. axTE3DWindowEx双屏对比控件白屏解决方法以及网上方法的校正(CreateControlOveride)
  7. Deep Learning(深度学习)学习笔记整理系列之(五)
  8. 【面试题】如何让C语言自动发现泄漏的内存
  9. [BZOJ 3144] [Hnoi2013] 切糕 【最小割】
  10. openwrt advanced configuration
  11. AngularJs学习笔记6——四大特性之依赖注入
  12. winmd文件和dll文件的区别
  13. C#动态调用WCF接口
  14. 【BZOJ3262】陌上花开 (CDQ分治+树状数组+排序)
  15. dubbo源码—dubbo简介
  16. h1-h3使用
  17. String,下表和切片,分割
  18. SpringMVC解决@ResponseBody返回Json的Date日期类型的转换问题
  19. zabbix3.4.6之自动发现与自动注册
  20. zabbix系列(三)zabbix3.0.4微信告警配置详解

热门文章

  1. 无密码通过ssh执行rsync
  2. 215. Kth Largest Element in an Array
  3. ZOJ 1056 The Worm Turns
  4. CentOS搭建Httpd Pyhton3 Django环境
  5. spark新能优化之数据本地化
  6. HDU5889 Barricade(最短路)(网络流)
  7. Android——多线程编程练习题
  8. Visible 绑定
  9. VS2013远程调试功能
  10. Linux perf tools