假设我们有以下 2 个数据库:
DROP DATABASE IF EXISTS `adb`;
CREATE DATABASE `adb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `adb`;
CREATE TABLE IF NOT EXISTS `Login` (
`ID` bigint(20) NOT NULL,
`Login` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `Login` (`ID`, `Login`) VALUES
(1, '2012-11-09 11:18:29'),
(2, '2012-12-22 21:48:48'),
(3, '2013-01-01 12:39:22');
DROP DATABASE IF EXISTS `bdat`;
CREATE DATABASE `bdat` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `bdat`;
CREATE TABLE IF NOT EXISTS `Login` (
`ID` bigint(20) NOT NULL,
`Login` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `Login` (`ID`, `Login`) VALUES
(1, '2011-11-09 15:15:15'),
(2, '2012-12-22 13:08:18'),
(3, '2010-02-11 17:00:02');
我们也有 2 个查询。
查询1是:
SELECT table_schema AS "Database", round(sum(data_length+index_length)/1024/1024,4) AS "Size (MB)" FROM information_schema.tables GROUP BY table_schema;
查询2是:
SELECT Max(Login) AS "Last Login" FROM Login
如何将两个查询组合在一起以获得以下结果?
Database Size (MB) Last Login
adb 0.0020 2012-12-22 13:08:18
bdat 0.0020 2013-01-01 12:39:22
information_schema 0.0078 NULL
mysql 0.6133 NULL