MySQL 是否有类似于 PostgreSQL 的扩展输出标志?
是的,可以使用 /G 代替分号 (;) 来在 MySQL 中获取扩展输出。语法如下
SELECT *FROM yourTableName\G
我们先创建一个表格作为示例
mysql> create table expandedOutputDemo - > ( - > EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, - > EmployeeName varchar(20), - > EmployeeAge int - > ); Query OK, 0 rows affected (0.66 sec)
使用插入命令在该表格中插入一些记录。
查询如下
mysql> insert into expandedOutputDemo(EmployeeName,EmployeeAge) values('Larry',27); Query OK, 1 row affected (0.16 sec) mysql> insert into expandedOutputDemo(EmployeeName,EmployeeAge) values('Mike',29); Query OK, 1 row affected (0.12 sec) mysql> insert into expandedOutputDemo(EmployeeName,EmployeeAge) values('Sam',31); Query OK, 1 row affected (0.10 sec) mysql> insert into expandedOutputDemo(EmployeeName,EmployeeAge) values('Bob',24); Query OK, 1 row affected (0.14 sec) mysql> insert into expandedOutputDemo(EmployeeName,EmployeeAge) values('Carol',28); Query OK, 1 row affected (0.09 sec)
使用选择语句从表格中显示所有记录。
查询如下
mysql> select *from expandedOutputDemo;
以下是输出内容
+------------+--------------+-------------+ | EmployeeId | EmployeeName | EmployeeAge | +------------+--------------+-------------+ | 1 | Larry | 27 | | 2 | Mike | 29 | | 3 | Sam | 31 | | 4 | Bob | 24 | | 5 | Carol | 28 | +------------+--------------+-------------+ 5 rows in set (0.00 sec)
以下是获取扩展输出的查询
mysql> select *from expandedOutputDemo\G
以下是输出内容
*************************** 1. row *************************** EmployeeId: 1 EmployeeName: Larry EmployeeAge: 27 *************************** 2. row *************************** EmployeeId: 2 EmployeeName: Mike EmployeeAge: 29 *************************** 3. row *************************** EmployeeId: 3 EmployeeName: Sam EmployeeAge: 31 *************************** 4. row *************************** EmployeeId: 4 EmployeeName: Bob EmployeeAge: 24 *************************** 5. row *************************** EmployeeId: 5 EmployeeName: Carol EmployeeAge: 28 5 rows in set (0.00 sec)
广告