您可以創建一個sql文件,然後添加一些像這樣的SELECT語句
// Does not print anyting
CREATE TABLE test (col1 int, col2 varchar(2));
// Prints a non-existing table with 1 column and 1 row
SELECT "CHECK 1" AS "Test result";
// This does prints some output
DESCRIBE test;
// Prints the check 'table' again
SELECT "CHECK 2" AS "Test result";
這樣的結果看起來像
[email protected]:~$ mysql -t -u root databasename < sqltest
+-------------+
| Test result |
+-------------+
| CHECK 1 |
+-------------+
+-------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| col1 | int(11) | YES | | NULL | |
| col2 | varchar(2) | YES | | NULL | |
+-------+------------+------+-----+---------+-------+
+-------------+
| Test result |
+-------------+
| CHECK 2 |
+-------------+
- 編輯,是因爲Dimitre的建議相同