Home > Database > Mysql Tutorial > 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
Release: 2023-09-07 20:41:12
forward
925 people have browsed it

除了使用分号 (;) 终止符之外,还有其他内置命令可以执行 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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template