我正在尝试编写
一个脚本,允许
用户选择他需要在表上执行的操作.我想检查表是否存在.如果它存在,我将继续其他事情,否则我
退出说表不存在.我怎么能实现这一点.
if [ $(MysqL -N -s -u root -p -e \
"select count(*) from information_schema.tables where \
table_schema='db_name' and table_name='table_name';") -eq 1 ]; then
do something
else
echo "table <table_name> does not exist"
exit 1
fi
> -N跳过列名> -s表示非表格输出