Document
Dayuser
 
社交按钮
963595946
首页
归档
标签
关于
友人帐

Powered by Dayuser | Theme: Fog
载入天数...
载入时分秒...
02/02/2020
2020-05-11
3 min read
mysql

mysql事务查询

--查看MySQL本次启动后的运行时间(单位:秒)
show status like 'uptime';

--查看select语句的执行数
show [global] status like 'com_select';

--查看insert语句的执行数
show [global] status like 'com_insert';

--查看update语句的执行数
show [global] status like 'com_update';

--查看delete语句的执行数
show [global] status like 'com_delete';

--查看试图连接到MySQL(不管是否连接成功)的连接数
show status like 'connections';

--查看线程缓存内的线程的数量。
show status like 'threads_cached';

--查看当前打开的连接的数量。
show status like 'threads_connected';

--查看当前打开的连接的数量。
show status like 'threads_connected';

--查看创建用来处理连接的线程数。如果Threads_created较大,你可能要增加thread_cache_size值。
show status like 'threads_created';

--查看激活的(非睡眠状态)线程数。
show status like 'threads_running';


--查看立即获得的表的锁的次数。
show status like 'table_locks_immediate';

--查看不能立即获得的表的锁的次数。如果该值较高,并且有性能问题,你应首先优化查询,然后拆分表或使用复制。
show status like 'table_locks_waited';

--查看创建时间超过slow_launch_time秒的线程数。
show status like 'slow_launch_threads';

--查看查询时间超过long_query_time秒的查询的个数。
show status like 'slow_queries';

--查询某库内的所有表
mysql -uroot -p123456 -Bse "select table_name from information_schema.tables where table_schema = 'database'

-- 查看正在执行的sql
show processlist

-- 如果表不存在则创建表
CREATE  TABLE IF NOT EXISTS new_table LIKE old_table; 

-- 交换字段位置 (字段1 前,字段2 后)
ALTER TABLE table_name CHANGE 字段2 字段2 varchar(45) AFTER  字段1;
-- 删除字段
ALTER TABLE table_name drop column ad_action_new;
-- 添加字段(在字段1 之后添加新字段)
ALTER TABLE table_name ADD COLUMN 新字段 varchar(45) AFTER  字段1;
-- 修改字段
ALTER TABLE table_name modify COLUMN column_name varchar(45) DEFAULT '0';
-- 添加索引
alter table TableName add index (列的列表) ;
-- 查看符号占多少字节
select length('1') from dual;//返回1,表示1个字符

下一篇 python(list)
/media/images/custom-bgimage.jpeg
Dayuser  |
  • 首页
  • 归档
  • 标签
  • 关于
  • 友链
2020-05-11
3 min read
mysql

mysql事务查询

--查看MySQL本次启动后的运行时间(单位:秒)
show status like 'uptime';

--查看select语句的执行数
show [global] status like 'com_select';

--查看insert语句的执行数
show [global] status like 'com_insert';

--查看update语句的执行数
show [global] status like 'com_update';

--查看delete语句的执行数
show [global] status like 'com_delete';

--查看试图连接到MySQL(不管是否连接成功)的连接数
show status like 'connections';

--查看线程缓存内的线程的数量。
show status like 'threads_cached';

--查看当前打开的连接的数量。
show status like 'threads_connected';

--查看当前打开的连接的数量。
show status like 'threads_connected';

--查看创建用来处理连接的线程数。如果Threads_created较大,你可能要增加thread_cache_size值。
show status like 'threads_created';

--查看激活的(非睡眠状态)线程数。
show status like 'threads_running';


--查看立即获得的表的锁的次数。
show status like 'table_locks_immediate';

--查看不能立即获得的表的锁的次数。如果该值较高,并且有性能问题,你应首先优化查询,然后拆分表或使用复制。
show status like 'table_locks_waited';

--查看创建时间超过slow_launch_time秒的线程数。
show status like 'slow_launch_threads';

--查看查询时间超过long_query_time秒的查询的个数。
show status like 'slow_queries';

--查询某库内的所有表
mysql -uroot -p123456 -Bse "select table_name from information_schema.tables where table_schema = 'database'

-- 查看正在执行的sql
show processlist

-- 如果表不存在则创建表
CREATE  TABLE IF NOT EXISTS new_table LIKE old_table; 

-- 交换字段位置 (字段1 前,字段2 后)
ALTER TABLE table_name CHANGE 字段2 字段2 varchar(45) AFTER  字段1;
-- 删除字段
ALTER TABLE table_name drop column ad_action_new;
-- 添加字段(在字段1 之后添加新字段)
ALTER TABLE table_name ADD COLUMN 新字段 varchar(45) AFTER  字段1;
-- 修改字段
ALTER TABLE table_name modify COLUMN column_name varchar(45) DEFAULT '0';
-- 添加索引
alter table TableName add index (列的列表) ;
-- 查看符号占多少字节
select length('1') from dual;//返回1,表示1个字符

下一篇 python(list)