tencent cloud

Cloud Log Service

SELECT Syntax

Download
聚焦模式
字号
最后更新时间: 2026-05-14 21:52:52
本文档由 AI 翻译
The SELECT statement is used to select data from a table. It selects eligible data from the current log topic by default.

Syntax Format

* | SELECT [Column name(KEY)]
SELECT obtains data from logs by default. The SELECT statement can be shortened as * | SELECT [column_name(KEY)] with FROM log omitted.
Note:
When you obtain data from a log topic, the maximum number of data rows that can be obtained is 100 by default. To obtain more data, use the LIMIT syntax to specify the desired number of rows (up to 1 million rows).

Syntax Example

Select values with columns (KEY) being remote_addr and method from the log data:
* | SELECT remote_addr, method
Select all columns (KEY) from the log data:
* | SELECT *
SELECT can also be followed by arithmetic expressions; for example, you can query the download speed of log data:
Download speed (speed) = total number of bytes sent (body_bytes_sent) / request time (request_time)
* | SELECT body_bytes_sent / request_time AS speed

Column Naming Conventions

In SQL specifications, a column name consists of letters, digits, and underscores and starts with a letter, such as remote_addr. If a field in a log has a non-compliant name, you need to surround the name by "". You can also specify an alias for the field with AS syntax in SQL.
If a log field is named remote_addr, which conforms to SQL's column naming conventions, it can be queried by SELECT:
* | SELECT remote_addr
If a log field is named __TAG__.pod_label_qcloud-app, which does not conform to SQL's column naming conventions, it needs to be surrounded by "":
* | SELECT "__TAG__.pod_label_qcloud-app"
If a log field is named __TIMESTAMP__, which does not conform to SQL's column naming conventions, it needs to be surrounded by "" and specified with an alias through the AS syntax:
* | SELECT "__TIMESTAMP__" AS log_time
The log field name is order, which conflicts with the ORDER BY syntax and must be enclosed in double quotation marks "":
* | SELECT "order"


帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈