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" != xst ]

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

相关推荐
u01092727119 分钟前
使用Scrapy框架构建分布式爬虫
jvm·数据库·python
l1t23 分钟前
DeekSeek辅助总结PostgreSQL Mistakes and How to Avoid Them 的一个例子
数据库·postgresql
醉风塘35 分钟前
JDBC批量操作终极指南:PreparedStatement批处理与事务性能优化实战
数据库·性能优化
2401_8384725138 分钟前
使用Python处理计算机图形学(PIL/Pillow)
jvm·数据库·python
invicinble1 小时前
对于mysql层对sql层面的知识体系的理解和把握
数据库·sql·mysql
2301_790300961 小时前
用Matplotlib绘制专业图表:从基础到高级
jvm·数据库·python
DFT计算杂谈1 小时前
VASP+PHONOPY+pypolymlpj计算不同温度下声子谱,附批处理脚本
java·前端·数据库·人工智能·python
数据知道1 小时前
PostgreSQL核心原理:为什么数据库偶尔会卡顿?
数据库·postgresql
Nandeska2 小时前
14、MySQL基于GTID的数据同步
数据库·mysql