gbase8s之mysql的show命令实现
第一步:生成show.sh脚本
cat /home/gbase/show.sh
#!/bin/bash
#作者:乡村野中医
#创作时间2024-11-21
#脚本名称show.sh
function show(){
#echo $#
if [ "xdatabases" = x$1 ]
then
echo "select name from sysdatabases;"|dbaccess sysmaster - 2>/dev/null|grep name|sed 's/name/\n/g'
elif [ "xtables" = x$1 ]
then
if [ "x" = "x${database_name}" ]
then
echo '请执行use 库名'
else
#echo "database_name:${database_name}"
echo "select tabname from systables where tabid>99;"|dbaccess $database_name - 2>/dev/null|grep tabname|sed 's/tabname/\n/g'
fi
else
echo '执行命令报错,想查看库请执行show databases'
fi
}
function use(){
if [ x != x$1 ]
then
read -p "gbase>" s t
if [ "xshow tables" != x$s$t ]
then
database_name=$1
#echo "database_name:$database_name"
show tables
fi
else
echo "语法报错,想查看某个库的表请执行 use 库名,show tables"
fi
}
第二步:写入gbasedbt用户的.bash_profile里
su - gbasedbt
echo "source show.sh" >> .bash_profile
第三步:测试命令
1,查看所有库
show databases
2,查看某库的所有业务表
use testdb
>show tables
原文地址:https://blog.csdn.net/weixin_55963561/article/details/143954488
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!