我們可以通過 MySQL 服務器支持的幾種方式添加注釋 –
# Comment
這個是單行注釋。這種注釋以 # 字符開始,直到行尾。
-– 注釋
?這也是單行注釋。后面必須跟空格或控制字符。
/* Comment */
這是多行注釋。此語法使注釋可以擴展到多行,因為開始和結束序列不必位于同一行。
考慮以下示例來演示所有三種類型的注釋 – p>
mysql> Select NOW() #Single line comment continues to the end of line -> ; +---------------------+ | NOW() | +---------------------+ | 2017-11-07 15:04:03 | +---------------------+ 1 row in set (0.00 sec) mysql> Select NOW() -- Single line comment continues to the end of line -> ; +---------------------+ | NOW() | +---------------------+ | 2017-11-07 15:04:17 | +---------------------+ 1 row in set (0.00 sec) mysql> Select 1 /* in-line comment */ +1; +-------+ | 1 +1 | +-------+ | 2 | +-------+ 1 row in set (0.10 sec) mysql> Select 1 /* in-line comment */ +1; +-------+ | 1 +1 | +-------+ | 2 | +-------+ 1 row in set (0.00 sec) mysql> Select 1 -> /* /*> this is a Multiple-line /*> comment /*> */ -> +1; +-------+ | 1 +1 | +-------+ | 2 | +-------+ 1 row in set (0.00 sec)
登錄后復制
以上就是MySQL查詢中添加注釋有哪幾種方式?的詳細內容,更多請關注www.92cms.cn其它相關文章!