Home  >  Article  >  Database  >  Besides using the semicolon (;) terminator, are there any other built-in commands for executing MySQL queries?

Besides using the semicolon (;) terminator, are there any other built-in commands for executing MySQL queries?

WBOY
WBOYforward
2023-09-07 20:41:12873browse

除了使用分号 (;) 终止符之外,还有其他内置命令可以执行 MySQL 查询吗?

#With the help of the following built-in commands, MySQL can execute queries even without using the semicolon (;) terminator.

ego

We can use this command by using \G option. It means to send the current statement to the server for execution and display the results in vertical format. When we use \G in a statement (single or multiple lines) and omit the semicolon (;), MySQL determines the end of the statement when it encounters \G. Consider the following example -

mysql> Select * from ratelist\G
*************************** 1. row ***************************
   Sr: 1
 Item: A
Price: 502
*************************** 2. row ***************************
Sr: 2
Item: B
Price: 630
*************************** 3. row ***************************
   Sr: 3
 Item: C
Price: 1005
*************************** 4. row ***************************
   Sr: 4
 Item: h
Price: 850
*************************** 5. row ***************************
   Sr: 5
 Item: T
Price: 250
5 rows in set (0.00 sec)

go

We can use this command by using \g option. It means sending the current statement to the server for execution. When we use \g in a statement (single or multiple lines) and omit the semicolon (;), MySQL determines that the statement ends when \g is encountered. It gives the same output format as what we get using semicolon (;). Consider the following example -

mysql> Select * from ratelist\g
+----+------+-------+
| Sr | Item | Price |
+----+------+-------+
|  1 | A    |   502 |
|  2 | B    |   630 |
|  3 | C    |  1005 |
|  4 | h    |   850 |
|  5 | T    |   250 |
+----+------+-------+
5 rows in set (0.00 sec)

The above is the detailed content of Besides using the semicolon (;) terminator, are there any other built-in commands for executing MySQL queries?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete