如何通过系统表查询带有 AUTO_ID_CACHE=1 的表有哪些?

#!/bin/bash

执行查询语句,并将结果存储到数组中

result=($(mysql -h tidb-ip -P 4000 -u root -p’’ -N -e “select TIDB_TABLE_ID from information_schema.tables where TABLE_SCHEMA=‘your_schema’”))

遍历数组

for item in “${result[@]}”
do
AUTO_ID_CACHE=$(curl -s http://tidb-ip:status-port/schema?table_id=${item} 2>/dev/null | grep ‘“auto_id_cache”: 1,’)
echo $AUTO_ID_CACHE

判断auto_id_cache的值是否为1,如果是则打印TABLE_SCHEMA和TABLE_NAME

if [[ ! -z $AUTO_ID_CACHE ]]; then
mysql -h tidb-ip -P 4000 -u root -p’’ -N -e “select TIDB_TABLE_ID,TABLE_SCHEMA,TABLE_NAME from information_schema.tables where TIDB_TABLE_ID=$item;”
fi
done