select concat('select * from ',TABLE_NAME,';') from information_schema.tables where TABLE_SCHEMA='xxx';
1、select concat('select * from ',TABLE_NAME,';') into outfile '/tmp/tbselect.sql' from information_schema.tables where TABLE_SCHEMA='dbname';--dbname修改成你要查询的数据库名 2、连接后通过source /tmp/tbselect.sql这就可以查询了。
取得所有表->打开游标循环->字符串累加生成SQL语句->再执行
2、连接后通过source /tmp/tbselect.sql这就可以查询了。