IDs, Paths, Strings, and Keywords
This article provides reference information for the following:
Identifiers are the names of collections, documents, fields, and other database objects.
Rule | Guidelines | Examples |
---|---|---|
Case-Sensitivity | Identifiers are always case-sensitive |
|
Non-Quoted Identifiers | Must start with a letter (A-Z or a-z) or an underscore Can contain only letters, digits, and underscores INVALID: Cannot use reserved keywords; for example:
|
|
Quoted Identifiers | Quote identifiers using backticks (``) Usage of double quotes ("") is deprecated Use any UTF-8 character Can be escaped inside existing delimiters |
|
The following table provides an overview of the DQL-specific restrictions that supersede common identifier rules:
Element | Rule |
---|---|
Document Identifier | _id is a reserved identifier for the document ID. All documents must have an assigned document ID. |
System Collection Identifiers | Double underscore (__) is a reserved identifier prefix for collections. Double underscore denotes a Ditto system collection. |
Since Ditto stores data as JSON-like documents, you can use keypath indexing, known commonly as dot syntax, to navigate and reference specific parts of a Ditto document when performing query operations in DQL.
To separate a name in a path, use a dot (.).
For example, to navigate to the seats field in a SELECT statement:
Following is an overview of the of the DQL-specific restrictions that supersede common rules:
Topic | Guideline |
---|---|
Path Evaluation | Path expressions are evaluated from left to right. For example, a.b.c:
|
Collections | Collection names cannot be present in path expressions. |
Types | Only REGISTER with nested JSON object and MAP types can be navigated with path expressions. |
MISSING | The path expression result is MISSING for the following conditions are both true:
|
Enclose string literals in single quotes ('') in DQL; for example 'blue' :
Double quotes ("") cannot be not used to represent string literals within DQL.
DQL supports both inline and multi-line comments.
Inline comments are made using the -- operator.
Multi-line comments are inclosed by the /* and */operator.
The following table provides a complete overview of the reserved keywords in DQL:
AGAINST ALL ALTER ANALYZE AND ANTI ANY APPLY ARRAY ARRAY_AGG AS ASC AT ATTACHMENT BETWEEN BIGINT BINARY BLOB BOOLEAN BOTH BY BYTEA CASE CAST CEIL CENTURY CHAR CHARACTER CHARACTERS CLOB CLUSTER COLLATE COLLECTION CONFLICT COUNT COUNTER CROSS CURRENT CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP DATE DATETIME DAY DEC DECADE DECIMAL DEFAULT DESC DISTINCT DISTRIBUTE DO DOCUMENTS DOUBLE DOW DOY ELSE END ENUM EPOCH ERROR ESCAPE EVICT EXCEPT EXISTS EXPANSION EXPLAIN EXTRACT FAIL FALSE FETCH FILTER FLOAT FLOOR FOLLOWING FOR FROM FULL GROUP GROUPS HAVING HOUR ID ILIKE IN INCREMENT INHERIT INITIAL INNER INSERT INT INTEGER INTERSECT INTERVAL INTO IS ISODOW ISOYEAR JOIN JULIAN LANGUAGE LARGE LATERAL LEADING LEFT LIKE LIMIT LISTAGG LOCALTIME LOCALTIMESTAMP
MAP MEDIUMINT MICROSECOND MICROSECONDS MILLENIUM MILLENNIUM MILLISECOND MILLISECONDS MINUTE MISSING MODE MONTH NANOSECOND NANOSECONDS NATURAL NOT NOTHING NULL NUMERIC NVARCHAR OBJECT OCTETS OFFSET ON OPERATOR OR ORDER OUTER OUTPUTFORMAT OVER OVERFLOW OVERLAY PARTITION PERCENT PLACING PNCOUNTER POSITION PRECEDING PRECISION QUALIFY QUARTER QUERY RANGE REAL REGCLASS REGISTER RESET RETURNING RIGHT ROW ROWS SAFE_CAST SECOND SELECT SEMI SET SHOW SIMILAR SMALLINT SORT STCOUNTER STRING SUBSTRING SYSTEM TABLE TEMP TEMPORARY TEXT THEN TIES TIME TIMESTAMP TIMESTAMPTZ TIMETZ TIMEZONE TIMEZONE_HOUR TIMEZONE_MINUTE TINYINT TO TOMBSTONE TOP TRAILING TRIM TRUE TRUNCATE TRY_CAST UNBOUNDED UNION UNKNOWN UNLOGGED UNNEST UNSIGNED UPDATE USING UUID VALID VALUES VARBINARY VARCHAR VARYING VIEW WEEK WHEN WHERE WITH WITHIN WITHOUT XOR YEAR ZONE