Identifiers
January 3, 2025About 1 min
Identifiers
In IoTDB, identifiers are used to identify database, table, column, function, or other object names.
1 Naming Rules
- First Character:Identifiers must begin with a letter.
- Subsequent Characters:Can include letters, numbers, and underscores.
- Special Characters:If an identifier contains characters other than letters, numbers, and underscores, it must be enclosed in double quotes (
"
). - Escape Character:Within double-quoted identifiers, two consecutive double quotes (
""
) are used to represent a single double quote character.
1.1 Examples
Here are some valid identifier examples:
test
"table$partitions"
"identifierWith"
"double"
"quotes"
Invalid identifier examples that must be quoted with double quotes:
table-name // contains a hyphen
123SchemaName // starts with a number
colum$name@field // contains special characters and is not enclosed in double quotes
2 Case Sensitivity
Identifiers are not case-sensitive, and the system does not retain the original case when storing identifiers. The column names in the query results will be displayed based on the case specified by the user in the SELECT clause.
Identifiers enclosed in double quotes are also not case-sensitive.
2.1 Example
When a column named Device_id
is created, it is seen as device_id
when viewing the table, but the returned result column matches the format specified by the user in the query as Device_ID
:
IoTDB> create table table1(Device_id STRING TAG, Model STRING ATTRIBUTE, TemPerature FLOAT FIELD, Humidity DOUBLE FIELD)
IoTDB> desc table1;
+-----------+---------+-----------+
| ColumnName| DataType| Category|
+-----------+---------+-----------+
| time|TIMESTAMP| TIME|
| device_id| STRING| TAG|
| model| STRING| ATTRIBUTE|
|temperature| FLOAT| FIELD|
| humidity| DOUBLE| FIELD|
+-----------+---------+-----------+
IoTDB> select TiMe, Device_ID, MoDEL, TEMPerature, HUMIdity from table1;
+-----------------------------+---------+------+-----------+--------+
| TiMe|Device_ID| MoDEL|TEMPerature|HUMIdity|
+-----------------------------+---------+------+-----------+--------+
|1970-01-01T08:00:00.001+08:00| d1|modelY| 27.2| 67.0|
+-----------------------------+---------+------+-----------+--------+