public final class IdentifierRules extends Object
定义数据库厂商的标识符大小写规则,区分 quoted 和 unquoted 标识符的处理方式。
设计来源:dbobject_search.md 资深设计师方案
使用示例:
// Oracle: unquoted 折叠为大写且不敏感,quoted 保留原样且敏感 IdentifierRules oracleRules = IdentifierRules.forOracle(); // Couchbase: 全部大小写敏感 IdentifierRules couchbaseRules = IdentifierRules.forCouchbase();
| Modifier and Type | Class and Description |
|---|---|
static class |
IdentifierRules.CaseCollapse
The mapping under which an
INSENSITIVE, non-folding branch
compares: two names are one name when their images are equal. |
static class |
IdentifierRules.CaseCompare
大小写比较规则(Case Comparison)
|
static class |
IdentifierRules.CaseFold
大小写折叠规则(Case Folding)
|
| Modifier and Type | Field and Description |
|---|---|
IdentifierRules.CaseCollapse |
collapse
How a branch of this cell that compares
INSENSITIVE but does
not fold (IdentifierRules.CaseFold.NONE) decides equality: two names are equal when their images
under this mapping are equal. |
int |
maxUtf8Bytes
The longest name the database keeps, in UTF-8 bytes; a longer name is cut to the longest
prefix of whole characters that fits, for storing and looking up alike, quoted or not.
|
static int |
POSTGRESQL_MAX_IDENTIFIER_BYTES
PostgreSQL's NAMEDATALEN - 1 with the default build (NAMEDATALEN = 64).
|
IdentifierRules.CaseCompare |
quotedCompare
Quoted 标识符的大小写比较规则
|
IdentifierRules.CaseFold |
quotedFold
Quoted 标识符的大小写折叠规则(通常为 NONE,保留原样)
|
IdentifierRules.CaseCompare |
unquotedCompare
Unquoted 标识符的大小写比较规则
|
IdentifierRules.CaseFold |
unquotedFold
Unquoted 标识符的大小写折叠规则
|
| Constructor and Description |
|---|
IdentifierRules(IdentifierRules.CaseFold unquotedFold,
IdentifierRules.CaseCompare unquotedCompare,
IdentifierRules.CaseFold quotedFold,
IdentifierRules.CaseCompare quotedCompare)
构造标识符规则
|
IdentifierRules(IdentifierRules.CaseFold unquotedFold,
IdentifierRules.CaseCompare unquotedCompare,
IdentifierRules.CaseFold quotedFold,
IdentifierRules.CaseCompare quotedCompare,
IdentifierRules.CaseCollapse collapse,
int maxUtf8Bytes)
构造标识符规则(完整参数)
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
static IdentifierRules |
forAccess()
Microsoft Access 标识符规则
|
static IdentifierRules |
forAnsi()
ANSI / ISO SQL 标识符规则(SQL-92 起的标准,与 Oracle 相同)
|
static IdentifierRules |
forAthena()
Athena 标识符规则(与 Presto 相同)
|
static IdentifierRules |
forBigQueryColumn()
BigQuery 列名规则(大小写不敏感)
|
static IdentifierRules |
forBigQueryTable()
BigQuery 表名规则(大小写敏感)
|
static IdentifierRules |
forCouchbase()
Couchbase N1QL 标识符规则
|
static IdentifierRules |
forDameng()
Dameng (达梦) 标识符规则(与 Oracle 相同)
|
static IdentifierRules |
forDatabricks()
Databricks 标识符规则(与 Hive 相同)
|
static IdentifierRules |
forDax()
DAX 标识符规则
|
static IdentifierRules |
forDB2()
DB2 / Netezza / Exasol 标识符规则(与 Oracle 相同)
|
static IdentifierRules |
forDoris()
Apache Doris 标识符规则(默认配置,相当于 lower_case_table_names=1)
|
static IdentifierRules |
forDoris(int lowerCaseTableNames)
Apache Doris 标识符规则(与 MySQL 相同)
|
static IdentifierRules |
forDorisColumn()
Apache Doris 列名规则(与 MySQL 列名相同,始终大小写不敏感)
|
static IdentifierRules |
forDuckDB()
DuckDB 标识符规则
|
static IdentifierRules |
forFirebird()
Firebird 标识符规则(与 Oracle 相同)
|
static IdentifierRules |
forFlink()
Apache Flink SQL 标识符规则
|
static IdentifierRules |
forGaussDB()
GaussDB 标识符规则(与 PostgreSQL 相同)
|
static IdentifierRules |
forGeneric()
通用规则(
dbvgeneric):没有具体方言时按 SQL 标准,见 forAnsi() |
static IdentifierRules |
forHANA()
SAP HANA 标识符规则(与 Oracle 相同)
|
static IdentifierRules |
forHive()
Hive / SparkSQL / Impala / Databricks 标识符规则
|
static IdentifierRules |
forMdx()
MDX 标识符规则
|
static IdentifierRules |
forMySQL(int lowerCaseTableNames)
MySQL 标识符规则(table/schema names)
|
static IdentifierRules |
forMySQLColumn()
MySQL 列名规则(始终大小写不敏感)
|
static IdentifierRules |
forMySQLNative(int lowerCaseTableNames)
MySQL table / schema / table-alias names, as verified on MySQL 8.4.10, used by
EDbVendor.dbvmysql. |
static IdentifierRules |
forMySQLNativeColumn()
MySQL column, column-alias and index names, as verified on MySQL 8.4.10: kept as written and
compared by the simple lowercase mapping (
IdentifierRules.CaseCollapse.LOWER_SIMPLE), whatever
lower_case_table_names is. |
static IdentifierRules |
forMySQLNativeRoutine()
MySQL function, procedure and routine-parameter names, as verified on MySQL 8.4.10: kept as
written; two names are the same when their simple UPPERCASE forms are equal
(
IdentifierRules.CaseCollapse.UPPER_SIMPLE), whatever lower_case_table_names is. |
static IdentifierRules |
forMySQLRoutine()
MySQL 函数名规则(始终大小写不敏感)
|
static IdentifierRules |
forOracle()
Oracle 标识符规则
|
static IdentifierRules |
forOracleNative()
Oracle 标识符规则,as verified on Oracle 23.26 (AL32UTF8), used by
EDbVendor.dbvoracle. |
static IdentifierRules |
forPostgreSQL()
PostgreSQL / Redshift / Greenplum 标识符规则
|
static IdentifierRules |
forPostgreSQLNative()
PostgreSQL 标识符规则,as verified on PostgreSQL 16.15 with a UTF8 database, used by
EDbVendor.dbvpostgresql. |
static IdentifierRules |
forPowerQuery()
Power Query M 标识符规则
|
static IdentifierRules |
forPresto()
Presto / Trino 标识符规则
|
static IdentifierRules |
forRedshift()
Amazon Redshift 标识符规则(默认配置,
enable_case_sensitive_identifier = false) |
static IdentifierRules |
forSnowflake()
Snowflake 标识符规则(与 Oracle 相同)
|
static IdentifierRules |
forSnowflake(boolean quotedIdentifiersIgnoreCase)
Snowflake 标识符规则(根据 QUOTED_IDENTIFIERS_IGNORE_CASE 决定)
|
static IdentifierRules |
forSqlAnywhere()
SAP IQ / SQL Anywhere 标识符规则
|
static IdentifierRules |
forSqlite()
SQLite 标识符规则
|
static IdentifierRules |
forSQLServer()
SQL Server / Azure SQL 标识符规则
|
static IdentifierRules |
forSQLServer(String collation)
SQL Server / Azure SQL 标识符规则(根据 collation 决定大小写比较)
|
static IdentifierRules |
forStarrocks()
StarRocks 标识符规则(默认配置,相当于 lower_case_table_names=1)
|
static IdentifierRules |
forStarrocks(int lowerCaseTableNames)
StarRocks 标识符规则(带参数,相当于 MySQL 的 lower_case_table_names)
|
static IdentifierRules |
forStarrocksColumn()
StarRocks 列名规则(与 MySQL 列名相同,始终大小写不敏感)
|
static IdentifierRules |
forSybase()
Sybase ASE 标识符规则
|
static IdentifierRules |
forTeradata()
Teradata 标识符规则
|
static IdentifierRules |
forVertica()
Vertica 标识符规则(与 Presto 相同)
|
int |
hashCode() |
IdentifierRules |
resolvedCell()
This cell with
IdentifierRules.CaseCompare.SAME_AS_UNQUOTED resolved — the form that identifies a
rule domain, so two cells that behave identically are not treated as two domains
merely because one spells its quoted compare as "same as unquoted". |
String |
toString() |
public final IdentifierRules.CaseFold unquotedFold
public final IdentifierRules.CaseCompare unquotedCompare
public final IdentifierRules.CaseFold quotedFold
public final IdentifierRules.CaseCompare quotedCompare
public final IdentifierRules.CaseCollapse collapse
INSENSITIVE but does
not fold (IdentifierRules.CaseFold.NONE) decides equality: two names are equal when their images
under this mapping are equal. IdentifierRules.CaseCollapse.SIMPLE_FOLD (Unicode simple case folding)
for every cell built with the four-argument constructor. A branch that folds is compared by
its folded text and never consults this.
Kept apart from the fold on purpose: the fold is the name a database STORES (what
IdentifierService.normalize(java.lang.String, gudusoft.gsqlparser.sqlenv.ESQLDataObjectType) returns), the collapse is only how it COMPARES. MySQL
keeps a column name as written but compares it by its simple lowercase mapping, so its
column cell is NONE with collapse IdentifierRules.CaseCollapse.LOWER_SIMPLE.
public final int maxUtf8Bytes
0 means no truncation. PostgreSQL: 63 (NAMEDATALEN - 1).public static final int POSTGRESQL_MAX_IDENTIFIER_BYTES
public IdentifierRules(IdentifierRules.CaseFold unquotedFold, IdentifierRules.CaseCompare unquotedCompare, IdentifierRules.CaseFold quotedFold, IdentifierRules.CaseCompare quotedCompare)
unquotedFold - unquoted 标识符的折叠规则unquotedCompare - unquoted 标识符的比较规则quotedFold - quoted 标识符的折叠规则quotedCompare - quoted 标识符的比较规则public IdentifierRules(IdentifierRules.CaseFold unquotedFold, IdentifierRules.CaseCompare unquotedCompare, IdentifierRules.CaseFold quotedFold, IdentifierRules.CaseCompare quotedCompare, IdentifierRules.CaseCollapse collapse, int maxUtf8Bytes)
unquotedFold - unquoted 标识符的折叠规则unquotedCompare - unquoted 标识符的比较规则quotedFold - quoted 标识符的折叠规则quotedCompare - quoted 标识符的比较规则collapse - how an INSENSITIVE branch that does not fold compares (collapse)maxUtf8Bytes - the length in UTF-8 bytes a name is cut to, 0 for none
(maxUtf8Bytes)public static IdentifierRules forOracle()
实际数据库行为(Oracle 12c+):
与 Legacy TSQLEnv 兼容性:
true → ❌ INCOMPATIBLE (legacy preserved case, new folds to UPPER)
true → ❌ INCOMPATIBLE (legacy preserved case, new folds to UPPER)
true → ❌ INCOMPATIBLE (legacy preserved case, new folds to UPPER)
false → ✅ COMPATIBLE (both fold to UPPER)
测试用例影响:
IdentifierRules 配置:
IdentifierRules.CaseFold.UPPER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较敏感 (IdentifierRules.CaseCompare.SENSITIVE)
Since 2026-10-11 this is the shape the Oracle-like FORKS share (DB2,
Netezza, Exasol, HANA, Snowflake, Dameng, Firebird), none of which has been verified on its
own engine. EDbVendor.dbvoracle itself uses
forOracleNative(): Oracle upper-cases an unquoted name with the SIMPLE mapping, so
straße is STRAßE, which this cell's full mapping turns into STRASSE.
public static IdentifierRules forOracleNative()
EDbVendor.dbvoracle.
IdentifierRules.CaseFold.UPPER_SIMPLE), case-insensitive.
CREATE TABLE straße is listed in user_tables as STRAßE (6
characters); FROM "STRAßE" finds it, FROM STRASSE raises ORA-00942.
IdentifierRules.CaseFold.NONE), case-sensitive.
SQL-LR oracle/rules-1, cell U_UPPER_SIMPLE_CI__Q_NONE_CS.
public static IdentifierRules forDameng()
Dameng follows Oracle identifier conventions:
public static IdentifierRules forPostgreSQL()
实际数据库行为(PostgreSQL 12+):
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (legacy folded to UPPER, new folds to LOWER)
true → ❌ INCOMPATIBLE (legacy preserved case, new folds to LOWER)
true → ❌ INCOMPATIBLE (legacy preserved case, new folds to LOWER)
true → ❌ INCOMPATIBLE (legacy preserved case, new folds to LOWER)
测试用例影响:
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较敏感 (IdentifierRules.CaseCompare.SENSITIVE)
Since 2026-10-11 this is the shape the PostgreSQL-like FORKS share
(Greenplum, GaussDB, EDB, and the fallback of Informix, OpenEdge and SOQL), none verified on
its own engine. EDbVendor.dbvpostgresql itself uses
forPostgreSQLNative().
public static IdentifierRules forPostgreSQLNative()
EDbVendor.dbvpostgresql.
A..Z are lowered (IdentifierRules.CaseFold.LOWER_ASCII) —
downcase_identifier lowers nothing else in a multibyte encoding. After
CREATE TABLE "Äbc", FROM ÄBC finds it and FROM "äbc" does not.
truncate_identifier / pg_mbcliplen), so two names that share their first
63 bytes are one name: CREATE TABLE <63 a>x is found by FROM <63 a>y.
SQL-LR postgresql/rules-1, cell U_LOWER_ASCII_CI__Q_NONE_CS with
truncation = UTF8_BYTES 63.
public static IdentifierRules forRedshift()
enable_case_sensitive_identifier = false)
实际数据库行为(AWS 文档 "Names and identifiers"):
standard 与 delimited identifier 都不区分大小写,并折叠为小写存储;
只有打开 enable_case_sensitive_identifier 时,delimited identifier 才保留大小写。
因此 "Orders"、"ORDERS" 与 orders 是同一个对象。
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
public static IdentifierRules forCouchbase()
实际数据库行为(Couchbase N1QL):
与 Legacy TSQLEnv 兼容性:
false → ❌ INCOMPATIBLE (legacy folded to UPPER, new preserves case)
IdentifierRules 配置:
IdentifierRules.CaseFold.NONE), 比较敏感 (IdentifierRules.CaseCompare.SENSITIVE)
IdentifierRules.CaseFold.NONE), 比较敏感 (IdentifierRules.CaseCompare.SENSITIVE)
public static IdentifierRules forSQLServer()
实际数据库行为(SQL Server 2019+):
与 Legacy TSQLEnv 兼容性:
false → ❌ INCOMPATIBLE (legacy folded to UPPER, new preserves case)
false → ❌ INCOMPATIBLE (legacy folded to UPPER, new preserves case)
false → ❌ INCOMPATIBLE (legacy folded to UPPER, new preserves case)
false → ❌ INCOMPATIBLE (legacy folded to UPPER, new preserves case)
测试用例影响:
IdentifierRules 配置:
IdentifierRules.CaseFold.NONE), 基于 collation 比较 (IdentifierRules.CaseCompare.COLLATION_BASED)
IdentifierRules.CaseFold.NONE), 基于 collation 比较 (IdentifierRules.CaseCompare.COLLATION_BASED)
CollatorProvider 使用,默认使用 SQL_Latin1_General_CP1_CI_AS (大小写不敏感)
注意:SQL Server 的大小写行为完全由 collation 决定,无法简单折叠。
public static IdentifierRules forSQLServer(String collation)
SQL Server 的大小写行为完全由 collation 决定:
Unquoted 和 quoted 标识符都保留原始大小写(CaseFold.NONE), 比较方式由 collation 名称中的 _CI_ 或 _CS_ 决定。
A case-sensitive collation is exact (IdentifierRules.CaseCompare.SENSITIVE), except
Latin1_General_CS_AI, whose accent equivalence was measured on the engine
(CollatorProvider.hasMeasuredAccentFolding(java.lang.String)): it compares through the collator
(IdentifierRules.CaseCompare.COLLATION_BASED), which folds accents by the measured table and then
compares exactly (verified on SQL Server 2022: under Latin1_General_CS_AI the table
café is found by cafe, not by Cafe). Every other collation, a
case-insensitive one or _BIN/_BIN2, compares through the collator. A
_CS_AI collation that was not measured stays exact, as before.
collation - SQL Server collation 名称(如 "SQL_Latin1_General_CP1_CS_AS"),
传 null 或空字符串使用默认(case-insensitive)public static IdentifierRules forMySQL(int lowerCaseTableNames)
实际数据库行为(MySQL 8.0+):
根据 lower_case_table_names 系统变量决定:
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (legacy folded to UPPER, new doesn't fold or folds to LOWER)
false → ⚠️ PARTIAL (legacy folded to UPPER, new doesn't fold)
false → ⚠️ PARTIAL (legacy folded to UPPER, new behavior depends on lower_case_table_names)
true → ⚠️ PARTIAL (legacy preserved case, new is insensitive)
测试用例影响:
IdentifierRules 配置:
IdentifierRules.CaseFold.NONE), 敏感 (IdentifierRules.CaseCompare.SENSITIVE)
IdentifierRules.CaseFold.LOWER), 不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
Since 2026-10-11 this is the shape the MySQL-like FORKS share (OceanBase,
Doris, StarRocks), none verified on its own engine.
EDbVendor.dbvmysql itself uses forMySQLNative(int).
lowerCaseTableNames - lower_case_table_names 值(0, 1, 2)public static IdentifierRules forMySQLNative(int lowerCaseTableNames)
EDbVendor.dbvmysql.
lower_case_table_names = 0: stored as given, case-sensitive (unchanged).
1: every name, quoted or not, is lowered with MySQL's one-to-one per-character
mapping (IdentifierRules.CaseFold.LOWER_SIMPLE); quoting does not create another name.
CREATE TABLE İ is stored as i, and FROM İ, FROM `İ` and
FROM i all find it. The quoted branch keeps its spelling as the stored form
GSP reports but compares by the same mapping (IdentifierRules.CaseCollapse.LOWER_SIMPLE).
2: stored as given, compared by the same lowercase mapping.
SQL-LR mysql/rules-1: cells U_LOWER_SIMPLE_CI__Q_LOWER_SIMPLE_CI and,
for lowerCaseTableNames = 0, U_NONE_CS__Q_NONE_CS.
lowerCaseTableNames - lower_case_table_names 值(0, 1, 2)public static IdentifierRules forMySQLNativeColumn()
IdentifierRules.CaseCollapse.LOWER_SIMPLE), whatever
lower_case_table_names is. CREATE TABLE c1(`ſ` int, s int) and
c2(`ς` int, `σ` int) succeed: those are distinct columns, which Unicode case folding
would merge. Index names follow the same rule (INDEX Idx then ADD INDEX idx
fails with ERROR 1061 even under lower_case_table_names = 0).public static IdentifierRules forMySQLNativeRoutine()
IdentifierRules.CaseCollapse.UPPER_SIMPLE), whatever lower_case_table_names is.
CREATE FUNCTION `ı`() is called by SELECT i(), and a later
CREATE FUNCTION i() fails as already existing; CREATE PROCEDURE pr(P int, p int)
fails with ERROR 1330 under lower_case_table_names = 0.public static IdentifierRules forMySQLColumn()
实际数据库行为(MySQL 8.0+):
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (legacy folded to UPPER, new preserves case but is INSENSITIVE)
Since 2026-10-11 the shape of the forks only; MySQL itself uses
forMySQLNativeColumn().
public static IdentifierRules forMySQLRoutine()
实际数据库行为(MySQL 8.0+):
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (legacy folded to UPPER, new preserves case but is INSENSITIVE)
Since 2026-10-11 the shape of the forks only; MySQL itself uses
forMySQLNativeRoutine().
public static IdentifierRules forBigQueryTable()
实际数据库行为(BigQuery Standard SQL):
与 Legacy TSQLEnv 兼容性:
false → ❌ INCOMPATIBLE (legacy folded to UPPER, new preserves case and is SENSITIVE)
false → ❌ INCOMPATIBLE (legacy folded to UPPER, new preserves case and is SENSITIVE)
测试用例影响:
public static IdentifierRules forBigQueryColumn()
实际数据库行为(BigQuery Standard SQL):
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (legacy folded to UPPER, new preserves case but is INSENSITIVE)
测试用例影响:
public static IdentifierRules forDB2()
实际数据库行为(DB2 11+):
与 Legacy TSQLEnv 兼容性:
true → ❌ INCOMPATIBLE (legacy preserved case, new folds to UPPER)
true → ❌ INCOMPATIBLE (legacy preserved case, new folds to UPPER)
forOracle() 的详细说明
public static IdentifierRules forSnowflake()
实际数据库行为(Snowflake):
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (both fold to UPPER, COMPATIBLE)
false → ⚠️ PARTIAL (both fold to UPPER, COMPATIBLE)
forOracle() 的详细说明
public static IdentifierRules forSnowflake(boolean quotedIdentifiersIgnoreCase)
Snowflake 默认行为:
当 QUOTED_IDENTIFIERS_IGNORE_CASE = TRUE 时:
quotedIdentifiersIgnoreCase - Snowflake QUOTED_IDENTIFIERS_IGNORE_CASE 参数public static IdentifierRules forHANA()
实际数据库行为(SAP HANA):
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (both fold to UPPER, COMPATIBLE)
forOracle() 的详细说明
public static IdentifierRules forPresto()
实际数据库行为(Presto/Trino):
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (legacy folded to UPPER, new folds to LOWER)
false → ⚠️ PARTIAL (legacy folded to UPPER, new folds to LOWER)
测试用例影响:
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 与 unquoted 一致 (IdentifierRules.CaseCompare.SAME_AS_UNQUOTED)
public static IdentifierRules forVertica()
实际数据库行为(Vertica):
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (legacy folded to UPPER, new folds to LOWER)
forPresto() 的详细说明
public static IdentifierRules forHive()
实际数据库行为:反引号只允许名字里出现特殊字符和保留字,不改变大小写规则,
所以 `Orders`、`ORDERS` 与 orders 是同一个对象:
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
`Amount` 显示为
Amount),只是比较时不区分;折叠会把元数据的写法改成小写。
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (legacy folded to UPPER, new folds to LOWER)
public static IdentifierRules forTeradata()
实际数据库行为:对象名不区分大小写,加不加双引号都一样;双引号只允许名字里
出现特殊字符和保留字。所以 "ORDERS"、"Orders" 与 orders 是同一个对象:
'"' || TRIM(TABLENAME) || '"'),SQL 里不带引号的引用必须能找到它们。
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
"ORDERS" 显示为
ORDERS),只是比较时不区分。
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (legacy folded to UPPER, new folds to LOWER)
public static IdentifierRules forAthena()
实际数据库行为(AWS Athena):
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (legacy folded to UPPER, new folds to LOWER)
forPresto() 的详细说明
public static IdentifierRules forGaussDB()
实际数据库行为(华为 GaussDB):
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL (legacy folded to UPPER, new folds to LOWER)
forPostgreSQL() 的详细说明
public static IdentifierRules forDatabricks()
实际数据库行为(Databricks "Identifiers"): "Identifiers are case-insensitive when referenced.",反引号标识符也一样, 按 UTF8_LCASE collation 比较。
IdentifierRules 配置:见 forHive()
(unquoted 与 quoted 都折叠为小写,比较不敏感)。
public static IdentifierRules forFlink()
实际数据库行为(Flink SQL Queries Overview):"Flink SQL uses a lexical
policy for identifier (table, attribute, function names) similar to Java: The case of
identifiers is preserved whether or not they are quoted. After which, identifiers are
matched case-sensitively." 反引号只允许名字里出现非字母数字字符,不改变大小写规则。
所以 `userId` 与 userId 是同一个名字,而 userId 与 userid
是两个名字。
IdentifierRules 配置:
IdentifierRules.CaseFold.NONE), 比较敏感 (IdentifierRules.CaseCompare.SENSITIVE)
IdentifierRules.CaseFold.NONE), 比较敏感 (IdentifierRules.CaseCompare.SENSITIVE)
与 Legacy TSQLEnv 兼容性:
false → ❌ INCOMPATIBLE (legacy compared case-insensitively)
public static IdentifierRules forDoris(int lowerCaseTableNames)
行为说明:
与 Legacy TSQLEnv 兼容性:
false → ⚠️ PARTIAL
true → ✅ COMPATIBLE
lowerCaseTableNames - lower_case_table_names 值(0, 1, 2),默认使用 1public static IdentifierRules forDoris()
行为说明:
public static IdentifierRules forDorisColumn()
public static IdentifierRules forStarrocks(int lowerCaseTableNames)
行为说明:
lowerCaseTableNames - lower_case_table_names 值(0, 1, 2),默认使用 1public static IdentifierRules forStarrocks()
行为说明:
public static IdentifierRules forStarrocksColumn()
public static IdentifierRules forSqlite()
实际数据库行为(SQLite 3.45.1 实测):名字不区分大小写,加不加引号都一样,
并保留定义时的大小写。CREATE TABLE "Orders" ("Amount" INT) 之后,
SELECT amount FROM orders、SELECT "amount" FROM "orders" 都能查到,
再建 "orders" 会报 table "orders" already exists。
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
public static IdentifierRules forSybase()
实际数据库行为(SAP IQ "Case-sensitivity of Identifiers" 对 ASE 的说明):
"In Adaptive Server Enterprise, the case-sensitivity of identifiers follows the
case-sensitivity of the data",即由服务器安装时的 sort order 决定;双引号只允许名字里出现
特殊字符和保留字,不改变大小写规则。GSP 按大小写不敏感的服务器建模(见
db_collation.md §2.12,与旧 TSQLEnv 一致),所以带不带引号都不区分大小写。
binary sort order(区分大小写)的服务器请用
IdentifierProfile.builder(gudusoft.gsqlparser.EDbVendor) 配置 NONE/SENSITIVE。
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
public static IdentifierRules forSqlAnywhere()
实际数据库行为:SAP IQ "Case-sensitivity of Identifiers":"SAP Sybase IQ does not support case-sensitive identifiers.";SQL Anywhere "Case Sensitivity":SQL Anywhere does not support case sensitive identifiers。加不加引号都不区分大小写,并保留定义时的大小写。
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
public static IdentifierRules forAccess()
实际数据库行为:Access 的表名、字段名不区分大小写;方括号只用来引用含特殊字符 或保留字的名字,不改变大小写规则,并保留定义时的大小写。
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
public static IdentifierRules forDax()
实际行为(Microsoft Learn "DAX syntax"):"All object names are
case-insensitive; for example, the names SALES and Sales would represent the same table."
单引号表名 'Sales'、方括号列名 [Amount] 也一样。
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
public static IdentifierRules forMdx()
实际行为:Analysis Services 默认不区分大小写(SQLBI "Letter case-sensitivity in
DAX, Power BI and Analysis Services":Power BI and Analysis Services are case-insensitive by
default),方括号界定的名字 [Measures].[Sales] 与 [measures].[sales] 相同。
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
public static IdentifierRules forPowerQuery()
实际行为(Microsoft Learn "Power Query M formula language"):M 区分大小写,
变量名、函数名都是("Because the Power Query M formula language is case sensitive, comparisons
between items that are identical but have different cases results in identifying the items
as being different")。#"Name" 形式只允许名字里出现空格等字符,不改变大小写规则。
IdentifierRules 配置:
IdentifierRules.CaseFold.NONE), 比较敏感 (IdentifierRules.CaseCompare.SENSITIVE)
IdentifierRules.CaseFold.NONE), 比较敏感 (IdentifierRules.CaseCompare.SENSITIVE)
public static IdentifierRules forDuckDB()
实际数据库行为(DuckDB "Keywords and Identifiers"):"Identifiers in DuckDB are always case-insensitive, similarly to PostgreSQL. However, unlike PostgreSQL (and some other major SQL implementations), DuckDB also treats quoted identifiers as case-insensitive." 同时保留定义时的大小写。
IdentifierRules 配置:
IdentifierRules.CaseFold.LOWER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
public static IdentifierRules forFirebird()
实际数据库行为(Firebird Language Reference, "Identifiers"):不带引号的名字
按大写存储,带引号的名字按原样存储、区分大小写。所以 "FULLNAME" 与 FULLNAME、
fullname、FullName 是同一个名字,而 "FullName" 与 FullName 不是。
IdentifierRules 配置:
IdentifierRules.CaseFold.UPPER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较敏感 (IdentifierRules.CaseCompare.SENSITIVE)
public static IdentifierRules forAnsi()
标准行为:regular identifier 不区分大小写,按大写处理(折叠为大写);
delimited identifier 保留原样、区分大小写。所以 "ORDERS" 与 orders 是同一个名字,
而 "orders" 与 orders 不是。
IdentifierRules 配置:
IdentifierRules.CaseFold.UPPER), 比较不敏感 (IdentifierRules.CaseCompare.INSENSITIVE)
IdentifierRules.CaseFold.NONE), 比较敏感 (IdentifierRules.CaseCompare.SENSITIVE)
public static IdentifierRules forGeneric()
dbvgeneric):没有具体方言时按 SQL 标准,见 forAnsi()public IdentifierRules resolvedCell()
IdentifierRules.CaseCompare.SAME_AS_UNQUOTED resolved — the form that identifies a
rule domain, so two cells that behave identically are not treated as two domains
merely because one spells its quoted compare as "same as unquoted".this when nothing needs resolving, else the resolved equivalent