标签:long har efault values height src port img $$
##查询慢查询时间,mysql默认10s SHOW VARIABLES LIKE ‘long_query_time‘;
##查询慢查询的次数 SHOW STATUS LIKE ‘slow_queries‘;
SHOW VARIABLES LIKE ‘log_queries_%‘
##修改OFF值为ON SET GLOBAL log_queries_not_using_indexes=ON; ##再次查看 SHOW VARIABLES LIKE ‘log_queries_%‘
SET GLOBAL long_query_time=0.9;
##重启查看慢查询时间
SHOW VARIABLES LIKE ‘long_query_time‘;
SHOW VARIABLES LIKE ‘slow_query_log‘;
SET GLOBAL slow_query_log=ON;
##再次查看
SHOW VARIABLES LIKE ‘slow_query_log‘;
SHOW VARIABLES LIKE ‘slow_query_log_file‘;
SET GLOBAL slow_query_log_file=‘E:\\mysqlerror.log‘
/*部门表*/ CREATE TABLE dept( deptno MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, /*编号*/ dname VARCHAR(20) NOT NULL DEFAULT "", /*名称*/ loc VARCHAR(13) NOT NULL DEFAULT "" /*地点*/ ) ENGINE=MYISAM DEFAULT CHARSET=utf8 ; /*员工表*/ CREATE TABLE emp (empno MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, /*编号*/ ename VARCHAR(20) NOT NULL DEFAULT "", /*名字*/ job VARCHAR(9) NOT NULL DEFAULT "",/*工作*/ mgr MEDIUMINT UNSIGNED NOT NULL DEFAULT 0,/*上级编号*/ hiredate DATE NOT NULL,/*入职时间*/ sal DECIMAL(7,2) NOT NULL,/*薪水*/ comm DECIMAL(7,2) NOT NULL,/*红利*/ deptno MEDIUMINT UNSIGNED NOT NULL DEFAULT 0 /*部门编号*/ )ENGINE=MYISAM DEFAULT CHARSET=utf8 ; /*薪水*/ CREATE TABLE salgrade ( grade MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, losal DECIMAL(17,2) NOT NULL, hisal DECIMAL(17,2) NOT NULL )ENGINE=MYISAM DEFAULT CHARSET=utf8; #测试数据leveof INSERT INTO salgrade VALUES (1,700,1200); INSERT INTO salgrade VALUES (2,1201,1400); INSERT INTO salgrade VALUES (3,1401,2000); INSERT INTO salgrade VALUES (4,2001,3000); INSERT INTO salgrade VALUES (5,3001,9999);
DELIMITER $$ CREATE FUNCTION rand_string(n INT) RETURNS VARCHAR(255) #该函数会返回一个字符串 BEGIN #chars_str定义一个变量 chars_str,类型是 varchar(100),默认值‘abcdefghijklmnopqrstuvwxyzABCDEFJHIJKLMNOPQRSTUVWXYZ‘; DECLARE chars_str VARCHAR(100) DEFAULT ‘abcdefghijklmnopqrstuvwxyzABCDEFJHIJKLMNOPQRSTUVWXYZ‘; DECLARE return_str VARCHAR(255) DEFAULT ‘‘; DECLARE i INT DEFAULT 0; WHILE i < n DO SET return_str =CONCAT(return_str,SUBSTRING(chars_str,FLOOR(1+RAND()*52),1)); SET i = i + 1; END WHILE; RETURN return_str; END $$
DELIMITER $$ CREATE FUNCTION rand_num() RETURNS INT(5) BEGIN DECLARE i INT DEFAULT 0; SET i =FLOOR(10+RAND()*500); RETURN i; END $$
DELIMITER $$ CREATE PROCEDURE insert_emp(IN START INT(10),IN max_num INT(10)) BEGIN DECLARE i INT DEFAULT 0; #set autocommit =0 把autocommit设置成0 SET autocommit = 0; REPEAT SET i = i + 1; INSERT INTO emp VALUES ((START+i) ,rand_string(6),‘SALESMAN‘,0001,CURDATE(),2000,400,rand_num()); UNTIL i = max_num END REPEAT; COMMIT; END $$
CALL insert_emp (100001,40000000);
SELECT * FROM emp WHERE empno=10005
标签:long har efault values height src port img $$
原文地址:https://www.cnblogs.com/Zzzzn/p/12331822.html