是的,您可以使用/ G(而不是分号(;))在MySQL中进行扩展。语法如下
SELECT *FROM yourTableName\G
让我们首先创建一个表作为示例
mysql> create table expandedOutputDemo - > ( - > EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, - > EmployeeName varchar(20), - > EmployeeAge int - > );
使用insert命令在表中插入一些记录。
查询如下
mysql> insert into expandedOutputDemo(EmployeeName,EmployeeAge) values('Larry',27); mysql> insert into expandedOutputDemo(EmployeeName,EmployeeAge) values('Mike',29); mysql> insert into expandedOutputDemo(EmployeeName,EmployeeAge) values('Sam',31); mysql> insert into expandedOutputDemo(EmployeeName,EmployeeAge) values('Bob',24); mysql> insert into expandedOutputDemo(EmployeeName,EmployeeAge) values('Carol',28);
使用select语句显示表中的所有记录。
查询如下
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)