mysql中\G和\g的作用

shixiu_yuan發表於2018-09-01

\g:等價於“;”

如下例項:

mysql> select * from t3\g
+------+----------+----------+-------+------------+---------------------+
| id   | username | password | money | birthday   | cztime              |
+------+----------+----------+-------+------------+---------------------+
|    1 | 使用者1    | 12346    |   500 | 1995-05-20 | 2018-07-30 09:40:30 |
+------+----------+----------+-------+------------+---------------------+
1 rows in set (0.00 sec)

mysql> select * from t3;
+------+----------+----------+-------+------------+---------------------+
| id   | username | password | money | birthday   | cztime              |
+------+----------+----------+-------+------------+---------------------+
|    1 | 使用者1    | 12346    |   500 | 1995-05-20 | 2018-07-30 09:40:30 |
+------+----------+----------+-------+------------+---------------------+   
1 rows in set (0.00 sec)

\G:j將查詢到的橫向表格縱向輸出,方便閱讀

如下例項: 
mysql> show create table t4; 
+——-+————————————————————————————————————————————————————-+ 
| Table | Create Table | 
+——-+————————————————————————————————————————————————————-+ 
| t4 | CREATE TABLE t4 ( 
id int(11) DEFAULT NULL, 
username varchar(20) DEFAULT NULL, 
money int(11) DEFAULT NULL 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 | 
+——-+————————————————————————————————————————————————————-+ 
1 row in set (0.00 sec)

mysql> show create table t4\G; 
***************** 1. row ***************** 
Table: t4 
Create Table: CREATE TABLE t4 ( 
id int(11) DEFAULT NULL, 
username varchar(20) DEFAULT NULL, 
money int(11) DEFAULT NULL 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 
1 row in set (0.00 sec)

ERROR: 
No query specified

mysql>

相關文章