mysql 把表放到内存中,MySQL将表的校验和存储在另一个表中

CONTEXT:

we have big databases with loads of tables. Most of them (99%) are using innodb.

we want to have a daily process that monitors which table has been modified. As they use innodb the value of Update_time from

SHOW table STATUS from information_schema;

is null.

For that reason we want to create a daily procedure that will store the checksum (and other stuffs for that matters) of each table somewhere (preferably another table). On that, we will do different checks.

PROBLEM:

I'm trying to use

checksum table from db_schema.table_name;

which returns a resultset-table with 2 columns: "table","checksum".

It gives me the value I want but I'm not able to use it in a select or insert statement.

I tried a lot of things like:

select `checksum` from (checksum table from db_schema.table_name);

or other similar queries. But I'm not able to extract the data from the resultset.

Is there a way I can do that?

Thanks in advance for your help.

EDIT: in the end what I want is to build a more complex resultset having different informations in it (table schema, table name, count, checksum, datetime:now()...)

Then I'll use this resultset to compare with the values of yesterday and draw my own statistics. That's why I want to get the checksum from that resultset.

解决方案

There is no possibility to save the result of CHECKSUM TABLE directly using SQL. Neither can you use prepared statements or cursors in stored procedures to use the checksum result.

You best make a script around it, or download some popular tools doing it for you.

For MyISAM tables using the CHECKSUM=1 table argument, you can simply use INFORMATION_SCHEMA like this:

SELECT TABLE_NAME,CHECKSUM FROM INFORMATION_SCHEMA.TABLES

WHERE TABLE_SCHEMA = 'test' AND ENGINE='MyISAM'

AND CHECKSUM IS NOT NULL;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值