mysql中的‘\G’ ‘\g’ ‘;’ navicat dbeaver
mysql中的‘\G’ ‘\g’ ‘;’ navicat dbeaver
省流:
在navicat、dbeaver等客户端中使用时,“\G”、“\g”、“;”都可以不需要。
正文:
“\G”、“\g”、“;”都是用来做sql的结束符用。“\g”、“;”作用完全等价。“\G”是将字段横排显示转换成纵列显示。
横排显示:
id |energy_type|factory|start_time |end_time |value |input_type|update_date |
-------------------+-----------+-------+-------------------+-------------------+--------+----------+-------------------+
1673669924273856513|1 |t1 |2023-06-01 00:00:00|2023-06-01 00:15:00|15.23152|input |2023-06-05 01:15:02|
1673669924319993858|1 |t1 |2023-06-02 00:15:00|2023-06-02 00:30:00|16.23152|input |2023-06-05 01:15:02|
1673669924319993859|1 |t1 |2023-06-02 00:30:00|2023-06-02 00:45:00|17.23152|auto |2023-06-05 00:15:02|
1673669924319993860|1 |t1 |2023-06-03 00:00:00|2023-06-03 00:15:00|18.23152|auto |2023-06-05 01:15:02|
1673669924319993861|1 |t1 |2023-06-03 00:15:00|2023-06-03 00:30:00|19.23152|input |2023-06-05 01:15:02|
1673669924319993862|1 |t1 |2023-06-04 00:00:00|2023-06-04 00:15:00|20.23152|auto |2023-06-05 01:15:02|
1673669924319993863|1 |t1 |2023-06-05 00:00:00|2023-06-05 00:15:00|21.23152|auto |2023-06-05 01:15:02|
1673669924319993864|1 |t2 |2023-06-05 00:15:00|2023-06-05 00:30:00|22.23152|auto |2023-06-05 01:15:02|
1673669924319993865|1 |t2 |2023-06-06 00:00:00|2023-06-06 00:15:00|15.23152|auto |2023-06-05 01:15:02|
纵列显示:
Name |Value |
-----------+-------------------+
id |1673669924273856513|
energy_type|1 |
factory |t1 |
start_time |2023-06-01 00:00:00|
end_time |2023-06-01 00:15:00|
value |15.23152 |
input_type |input |
update_date|2023-06-05 01:15:02|
这里显示的是其中一列,可以翻下一页,就能看到下一条。
MYSQL中‘;’、‘\g’、‘\G’三者的作用和区别_勾起你的BUG的博客-CSDN博客
使用场景:
什么时候会用到纵列显示呢?
查看数据库配置,例如:
show slave status;
会显示很长,这时候就需要让结果纵列显示。
在navicat等客户端中,可以直接点击纵列显示,但在cmd命令框中,就需要用\G。
show slave status\G
结果显示如下:
Name |Value |
-----------------------------+------------------------------------------------------+
Slave_IO_State |Waiting for master to send event |
Master_Host |192.168.20.161 |
Master_User |root |
Master_Port |3306 |
Connect_Retry |60 |
Master_Log_File |mysql-bin.004651 |
Read_Master_Log_Pos |300004719 |
Relay_Log_File |xxxx-relay-bin.002999 |
Relay_Log_Pos |300004932 |
Relay_Master_Log_File |mysql-bin.004651 |
Slave_IO_Running |Yes |
Slave_SQL_Running |Yes |
Replicate_Do_DB |alisaas |
Replicate_Ignore_DB |mysql,information_schema,performation_schema,sys |
Replicate_Do_Table | |
Replicate_Ignore_Table | |
Replicate_Wild_Do_Table | |
Replicate_Wild_Ignore_Table | |
Last_Errno |0 |
Last_Error | |
Skip_Counter |0 |
Exec_Master_Log_Pos |300004719 |
Relay_Log_Space |300005190 |
Until_Condition |None |
Until_Log_File | |
Until_Log_Pos |0 |
Master_SSL_Allowed |No |
Master_SSL_CA_File | |
Master_SSL_CA_Path | |
Master_SSL_Cert | |
Master_SSL_Cipher | |
Master_SSL_Key | |
Seconds_Behind_Master |0 |
Master_SSL_Verify_Server_Cert|No |
Last_IO_Errno |0 |
Last_IO_Error | |
Last_SQL_Errno |0 |
Last_SQL_Error | |
Replicate_Ignore_Server_Ids | |
Master_Server_Id |161 |
Master_UUID |000fe6d4-25cd-21eb-a102-1111efa99c99 |
Master_Info_File |/sata01/data/mysql/master.info |
SQL_Delay |0 |
SQL_Remaining_Delay | |
Slave_SQL_Running_State |Slave has read all relay log; waiting for more updates|
Master_Retry_Count |86400 |
Master_Bind | |
Last_IO_Error_Timestamp | |
Last_SQL_Error_Timestamp | |
Master_SSL_Crl | |
Master_SSL_Crlpath | |
Retrieved_Gtid_Set | |
Executed_Gtid_Set | |
Auto_Position |0 |
Replicate_Rewrite_DB | |
Channel_Name | |
Master_TLS_Version | |
=====================分割线=======================
文章到此已经结束,以下是紫薯布丁
id |energy_type|factory|start_time |end_time |value |input_type|update_date |
-------------------+-----------+-------+-------------------+-------------------+--------+----------+-------------------+
1673669924273856513|1 |t1 |2023-06-01 00:00:00|2023-06-01 00:15:00|15.23152|input |2023-06-05 01:15:02|
1673669924319993858|1 |t1 |2023-06-02 00:15:00|2023-06-02 00:30:00|16.23152|input |2023-06-05 01:15:02|
1673669924319993859|1 |t1 |2023-06-02 00:30:00|2023-06-02 00:45:00|17.23152|auto |2023-06-05 00:15:02|
1673669924319993860|1 |t1 |2023-06-03 00:00:00|2023-06-03 00:15:00|18.23152|auto |2023-06-05 01:15:02|
1673669924319993861|1 |t1 |2023-06-03 00:15:00|2023-06-03 00:30:00|19.23152|input |2023-06-05 01:15:02|
1673669924319993862|1 |t1 |2023-06-04 00:00:00|2023-06-04 00:15:00|20.23152|auto |2023-06-05 01:15:02|
1673669924319993863|1 |t1 |2023-06-05 00:00:00|2023-06-05 00:15:00|21.23152|auto |2023-06-05 01:15:02|
1673669924319993864|1 |t2 |2023-06-05 00:15:00|2023-06-05 00:30:00|22.23152|auto |2023-06-05 01:15:02|
1673669924319993865|1 |t2 |2023-06-06 00:00:00|2023-06-06 00:15:00|15.23152|auto |2023-06-05 01:15:02|
Name |Value |
-----------+-------------------+
id |1673669924273856513|
energy_type|1 |
factory |t1 |
start_time |2023-06-01 00:00:00|
end_time |2023-06-01 00:15:00|
value |15.23152 |
input_type |input |
update_date|2023-06-05 01:15:02|
Name |Value |
-----------------------------+------------------------------------------------------+
Slave_IO_State |Waiting for master to send event |
Master_Host |192.168.20.161 |
Master_User |root |
Master_Port |3306 |
Connect_Retry |60 |
Master_Log_File |mysql-bin.004651 |
Read_Master_Log_Pos |300004719 |
Relay_Log_File |xxxx-relay-bin.002999 |
Relay_Log_Pos |300004932 |
Relay_Master_Log_File |mysql-bin.004651 |
Slave_IO_Running |Yes |
Slave_SQL_Running |Yes |
Replicate_Do_DB |alisaas |
Replicate_Ignore_DB |mysql,information_schema,performation_schema,sys |
Replicate_Do_Table | |
Replicate_Ignore_Table | |
Replicate_Wild_Do_Table | |
Replicate_Wild_Ignore_Table | |
Last_Errno |0 |
Last_Error | |
Skip_Counter |0 |
Exec_Master_Log_Pos |300004719 |
Relay_Log_Space |300005190 |
Until_Condition |None |
Until_Log_File | |
Until_Log_Pos |0 |
Master_SSL_Allowed |No |
Master_SSL_CA_File | |
Master_SSL_CA_Path | |
Master_SSL_Cert | |
Master_SSL_Cipher | |
Master_SSL_Key | |
Seconds_Behind_Master |0 |
Master_SSL_Verify_Server_Cert|No |
Last_IO_Errno |0 |
Last_IO_Error | |
Last_SQL_Errno |0 |
Last_SQL_Error | |
Replicate_Ignore_Server_Ids | |
Master_Server_Id |161 |
Master_UUID |000fe6d4-25cd-21eb-a102-1111efa99c99 |
Master_Info_File |/sata01/data/mysql/master.info |
SQL_Delay |0 |
SQL_Remaining_Delay | |
Slave_SQL_Running_State |Slave has read all relay log; waiting for more updates|
Master_Retry_Count |86400 |
Master_Bind | |
Last_IO_Error_Timestamp | |
Last_SQL_Error_Timestamp | |
Master_SSL_Crl | |
Master_SSL_Crlpath | |
Retrieved_Gtid_Set | |
Executed_Gtid_Set | |
Auto_Position |0 |
Replicate_Rewrite_DB | |
Channel_Name | |
Master_TLS_Version | |
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)