时间:2020-10-19来源:www.pcxitongcheng.com作者:电脑系统城
SELECT COUNT(*)
FROM information_schema.tables t1
LEFT OUTER JOIN information_schema.table_constraints t2
ON t1.table_schema = t2.table_schema
AND t1.table_name = t2.table_name
AND t2.constraint_name IN ( 'PRIMARY' )
WHERE t2.table_name IS NULL
AND t1.table_schema NOT IN ( 'information_schema', 'myawr', 'mysql',
'performance_schema',
'slowlog', 'sys', 'test' )
AND t1.table_type = 'BASE TABLE'
mysql> GRANT SELECT ON information_schema.TABLES TO test@'%';
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'information_schema'
DELIMITER //
CREATE DEFINER=`root`@`localhost` PROCEDURE `moitor_without_primarykey`()
BEGIN
SELECT COUNT(*)
FROM information_schema.tables t1
LEFT OUTER JOIN information_schema.table_constraints t2
ON t1.table_schema = t2.table_schema
AND t1.table_name = t2.table_name
AND t2.constraint_name IN ( 'PRIMARY' )
WHERE t2.table_name IS NULL
AND t1.table_schema NOT IN ( 'information_schema', 'myawr', 'mysql',
'performance_schema',
'slowlog', 'sys', 'test' )
AND t1.table_type = 'BASE TABLE';
END //
DELIMITER ;
mysql> GRANT EXECUTE ON PROCEDURE moitor_without_primarykey TO 'test'@'%';
Query OK, 0 rows affected (0.02 sec)
mysql> select current_user();
+----------------+
| current_user() |
+----------------+
| test@% |
+----------------+
1 row in set (0.00 sec)
mysql> call moitor_without_primarykey;
+----------+
| COUNT(*) |
+----------+
| 6 |
+----------+
1 row in set (0.02 sec)
Query OK, 0 rows affected (0.02 sec)
mysql> show grants for test@'%';
+-------------------------------------------------------------------------------+
| Grants for test@% |
+-------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `test`@`%` |
| GRANT EXECUTE ON PROCEDURE `zabbix`.`moitor_without_primarykey` TO `test`@`%` |
+-------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
2023-10-30
windows上的mysql服务突然消失提示10061 Unkonwn error问题及解决方案2023-10-30
MySQL非常重要的日志bin log详解2023-10-30
详解MySQL事务日志redo log一、单表查询 1、排序 2、聚合函数 3、分组 4、limit 二、SQL约束 1、主键约束 2、非空约束 3、唯一约束 4、外键约束 5、默认值 三、多表查询 1、内连接 1)隐式内连接: 2)显式内连接: 2、外连接 1)左外连接 2)右外连接 四...
2023-10-30
Mysql删除表重复数据 表里存在唯一主键 没有主键时删除重复数据 Mysql删除表中重复数据并保留一条 准备一张表 用的是mysql8 大家自行更改 创建表并添加四条相同的数据...
2023-10-30