// 查看当前默认存储引擎
mysql >show variables like'table_type';// 查看当前数据库支持的存储引擎// -- 方法1:
mysql >show engines \G
// -- 方法2:
mysql >show variables like'have%';
2 表
2.1 表的索引
// 查看索引
mysql >showindexfrom tabname \G;// 删除索引
mysql >dropindex mem_hash on tabname;
2.2 建表语句
mysql >showcreatetable emp \G;
3 创造测试数据
mysql >insertinto t values(1,repeat('haha',100));
4 对表进行优化
mysql >optimizetable t;
5 blob
mysql >createtable t(id varchar(100),context blob,hash_value varchar(40));
mysql >insertinto t values(1,repeat('beijing',2),md5(context);
6 查看可用的字符集
mysql >showcharacterset;// 查看字符集和校对规则
mysql >desc information_schema.character_set;// 查看校对规则
mysql >show collation like'gbk%';// 字符集设置-- my.cnf character-set-server=gbk
-- 启动项中指定
mysqld --character-set-server=gbk-- 编译时指定
shell>cmake .-DDEFAULY_CHARSET=gbk
// 查看当前服务器字符集和校验规则
mysql >show variables like'character_set_server';
mysql >show variables like'collation_server';
7 执行计划explain
mysql >explainselect*from city where city='zhengzhou' \G
8 查看视图
// 视图的定义语句
mysql >showcreateview staff_list \G
mysql >select*from views where table_name='staff_list' \G
9 修改语句结束符DELIMITER
// 将语句结束符由;改为$$
mysql >DELIMITER $$
10 查看触发器
mysql >show triggers \G
11 分布式事务XA命令
// 启动分支事务-- xa的grtid 为test,bqual为db1
mysql > xa start'test1','db1';// 分支事务1为:
mysql >insertinto actor(actor_id,first_name,last_name)values(301,'Simon','Tom');// 结束分支事务
mysql > xa end'test1','db1';// 进入prepare状态
mysql > xa prepare'test1','db1';// 查看分支事务
mysql > xa recover \G
// 提交分支事务
mysql > xa commit'test1','db1';
12 查看warning
mysql >insertintovalues('12798723048309','beijing');
Query OK,1row affected,1 warning(0.00 sec)
mysql >show warning;