分享交流
合作共赢!

Mysql基础使用方法总结【一】

一、mysql查看存储过程函数

1.查询数据库中的存储过程和函数
select `name` from mysql.proc where db = 'xx' and `type` = 'PROCEDURE'   //存储过程
select `name` from mysql.proc where db = 'xx' and `type` = 'FUNCTION'   //函数

show procedure status; //存储过程
show function status;     //函数

2.查看存储过程或函数的创建代码

show create procedure proc_name;
show create function func_name;

3.查看视图

SELECT * from information_schema.VIEWS   //视图
SELECT * from information_schema.TABLES   //表

4.查看触发器

SHOW TRIGGERS [FROM db_name] [LIKE expr]
SELECT * FROM triggers T WHERE trigger_name=”mytrigger” \G

二、Mysql查看数据库及数据表大小

用SQL命令查看Mysql数据库大小

要想知道每个数据库的大小的话,步骤如下:

1、进入information_schema 数据库(存放了其他的数据库的信息)

use information_schema;

2、查询所有数据的大小:

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;

3、查看指定数据库的大小:

比如查看数据库home的大小

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='home';

4、查看指定数据库的某个表的大小

比如查看数据库home中 members 表的大小

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='home' and table_name='members';

三、不进入Mysql执行mysql命令方法

1.使用-e参数
mysql -u root -p xxxxxx -e "show databases;"

2.使用eof写入命令

mysql -u root -p xxxxxx << eof 
show databases; 
eof

3.使用echo 命令写入

echo "show databases;" | mysql -u root -p xxxxxx

4.将命令写入sql 文件并执行

cat show.sql show databases; mysql -u root -p xxxxxx < show.sql

5.参数传递

MYSQLCMD="mysql -hhost -uuser -ppasswd db" CODE="SELECT * FROM table" echo "${CODE}" | ${MYSQLCMD}
赞(0) 打赏
未经允许不得转载:琼杰笔记 » Mysql基础使用方法总结【一】

评论 抢沙发

评论前必须登录!

 

分享交流,合作共赢!

联系我们加入QQ群

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册