<@U0A71G31CDV> I was thinking that "timestamp" co...
# questions-and-troubleshooting
m
@Rocky I was thinking that "timestamp" column having in a create table will fail then i have to provide with a backticks but still it did work without having backticks so help me understand. CREATE TABLE IF NOT EXISTS user_activity_log ( user_id BIGINT NOT NULL COMMENT "Unique user identifier", event_type *VARCHAR*(50) NOT NULL COMMENT "Type of action performed", device_info *VARCHAR*(100) COMMENT "Client device metadata", -- Timestamp column mapping timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT "Time of the event" ) ENGINE = OLAP DUPLICATE *KEY*(user_id, event_type) PARTITION BY *RANGE*(timestamp) ( PARTITION p20260817 VALUES LESS THAN ("2026-08-18 000000"), PARTITION p20260818 VALUES LESS THAN ("2026-08-19 000000") ) DISTRIBUTED BY HASH(user_id) BUCKETS 8 PROPERTIES ( "replication_num" = "3" );
✅ 1
r
In StarRocks, keywords are divided into two categories: Reserved and Non-reserved. The reason your
CREATE TABLE
statement worked without backticks is that
timestamp
is a non-reserved keyword
in StarRocks. 1. Non-Reserved vs. Reserved Keywords * Non-reserved keywords: These have special meaning to the SQL parser (like
TIMESTAMP
which is a function name) but can still be used as identifiers (table names, column names) without backticks. * Reserved keywords: These cannot be used as identifiers unless you enclose them in backticks (`` ` ``). Examples include
SELECT
,
CREATE
,
TABLE
, and
CURRENT_TIMESTAMP
. 2. Why
timestamp
specifically?
While
timestamp
is a reserved keyword in some other database systems, StarRocks follows a specific list of reserved words. If you check the official list of StarRocks Reserved Keywords, you will find: * `CURRENT_TIMESTAMP`: Reserved (which is why it's used as a function in your
DEFAULT
clause). * `LOCALTIMESTAMP`: Reserved. * `TIMESTAMP`: Not Reserved. Because
timestamp
is not in the reserved list, the parser is able to distinguish between the column name
timestamp
and the data type or function in the context of your SQL statement. Recommendation Even though it worked without backticks, it is generally considered best practice to use backticks for column names that match common SQL types or functions (like
timestamp
,
date
,
key
, etc.). This prevents potential syntax errors if a future version of StarRocks moves that keyword into the "Reserved" category or if you migrate your DDL to a different system where it is reserved.
Copy code
sql
-- Recommended practice
`timestamp` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
References • sql-reference/sql-statements/keywords.md • release_notes/release-2.5.md • sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE.md • sql-reference/System_limit.md • administration/management/FE_configuration.md