Identifier

Usage scenarios

Certain objects within IoTDB, including TRIGGER, FUNCTION(UDF), CONTINUOUS QUERY, SCHEMA TEMPLATE, USER, ROLE,Pipe,PipeSink,alias and other object names are known as identifiers.

Constraints

Below are basic constraints of identifiers, specific identifiers may have other constraints, for example, user should consists of more than 4 characters.

  • Permitted characters in unquoted identifiers:
    • [0-9 a-z A-Z _ ] (letters, digits and underscore)
    • [‘\u2E80’..’\u9FFF’] (UNICODE Chinese characters)
  • Identifiers may begin with a digit, unquoted identifiers can not be a real number.
  • Identifiers are case sensitive.
  • Key words can be used as an identifier.

You need to quote the identifier with back quote(`) in the following cases:

  • Identifier contains special characters.
  • Identifier that is a real number.

How to use quotations marks in quoted identifiers

' and " can be used directly in quoted identifiers.

` may be written as `` in quoted identifiers. See the example below:

  1. # create template t1't"t
  2. create schema template `t1't"t`
  3. (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY)
  4. # create template t1`t
  5. create schema template `t1``t`
  6. (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY)

Examples

Examples of case in which quoted identifier is used :

  • Trigger name should be quoted in cases described above :

    1. # create trigger named alert.`listener-sg1d1s1
    2. CREATE TRIGGER `alert.listener-sg1d1s1`
    3. AFTER INSERT
    4. ON root.sg1.d1.s1
    5. AS 'org.apache.iotdb.db.engine.trigger.example.AlertListener'
    6. WITH (
    7. 'lo' = '0',
    8. 'hi' = '100.0'
    9. )
  • UDF name should be quoted in cases described above :

    1. # create a funciton named 111, 111 is a real number.
    2. CREATE FUNCTION `111` AS 'org.apache.iotdb.udf.UDTFExample'
  • Template name should be quoted in cases described above :

    1. # create a template named 111, 111 is a real number.
    2. create schema template `111`
    3. (temperature FLOAT encoding=RLE, status BOOLEAN encoding=PLAIN compression=SNAPPY)
  • User and Role name should be quoted in cases described above, blank space is not allow in User and Role name whether quoted or not :

    1. # create user special`user.
    2. CREATE USER `special``user.` 'write_pwd'
    3. # create role 111
    4. CREATE ROLE `111`
  • Continuous query name should be quoted in cases described above :

    1. # create continuous query test.cq
    2. CREATE CONTINUOUS QUERY `test.cq`
    3. BEGIN
    4. SELECT max_value(temperature)
    5. INTO temperature_max
    6. FROM root.ln.*.*
    7. GROUP BY time(10s)
    8. END
  • Pipe、PipeSink should be quoted in cases described above :

    1. # create PipeSink test.*1
    2. CREATE PIPESINK `test.*1` AS IoTDB ('ip' = '输入你的IP')
    3. # create Pipe test.*2
    4. CREATE PIPE `test.*2` TO `test.*1` FROM
    5. (select ** from root WHERE time>=yyyy-mm-dd HH:MM:SS) WITH 'SyncDelOp' = 'true'
  • AS function provided by IoTDB can assign an alias to time series selected in query. Alias can be constant(including string) or identifier.

    1. select s1 as temperature, s2 as speed from root.ln.wf01.wt01;
    2. # Header of result dataset
    3. +-----------------------------+-----------|-----+
    4. | Time|temperature|speed|
    5. +-----------------------------+-----------|-----+
  • The key/value of an attribute can be String Literal and identifier, more details can be found at key-value pair part.