enable_case_sensitive_identifier - Amazon Redshift
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

enable_case_sensitive_identifier

Values (default in bold)

true, false

Description

A configuration value that determines whether name identifiers of databases, tables, and columns are case sensitive. The case of name identifiers is preserved when enclosed within double quotation marks. When you set enable_case_sensitive_identifier to true, the case of name identifiers is preserved. When you set enable_case_sensitive_identifier to false, the case of name identifiers is not preserved.

The case of a username enclosed in double quotation marks is always preserved regardless of the setting of the enable_case_sensitive_identifier configuration option.

Examples

The following example shows how to create and use case sensitive identifiers for a table and column name.

-- To create and use case sensitive identifiers SET enable_case_sensitive_identifier TO true; -- Create tables and columns with case sensitive identifiers CREATE TABLE "MixedCasedTable" ("MixedCasedColumn" int); CREATE TABLE MixedCasedTable (MixedCasedColumn int); -- Now query with case sensitive identifiers SELECT "MixedCasedColumn" FROM "MixedCasedTable"; MixedCasedColumn ------------------ (0 rows) SELECT MixedCasedColumn FROM MixedCasedTable; mixedcasedcolumn ------------------ (0 rows)

The following example shows when the case of identifiers is not preserved.

-- To not use case sensitive identifiers RESET enable_case_sensitive_identifier; -- Mixed case identifiers are lowercased CREATE TABLE "MixedCasedTable2" ("MixedCasedColumn" int); CREATE TABLE MixedCasedTable2 (MixedCasedColumn int); ERROR: Relation "mixedcasedtable2" already exists SELECT "MixedCasedColumn" FROM "MixedCasedTable2"; mixedcasedcolumn ------------------ (0 rows) SELECT MixedCasedColumn FROM MixedCasedTable2; mixedcasedcolumn ------------------ (0 rows)

Usage Notes

  • If you're using autorefresh for materialized views, we recommend setting the enable_case_sensitive_identifier value in your cluster or workgroup's parameter group. This ensures that enable_case_sensitive_identifier stays constant when your materialized views are refreshed. For information on autorefresh for materialized views, see Refreshing a materialized view. For information on setting configuration values in parameter groups, see Amazon Redshift parameter groups in the Amazon Redshift Management Guide.

  • If you're using row-level security or dynamic data masking features, we recommend setting the enable_case_sensitive_identifier value in your cluster or workgroup's parameter group. This ensures that enable_case_sensitive_identifier stays constant throughout creating and attaching a policy, and then querying a relation that has a policy applied. For information on row-level security, see Row-level security. For information on dynamic data masking, see Dynamic data masking.

  • When you set enable_case_sensitive_identifier to on and create a table, you can set case sensitive column names. When you set enable_case_sensitive_identifier to off and query the table, the column names are downcased. This can produce query results different from when enable_case_sensitive_identifier is set to on. Consider the following example:

    SET enable_case_sensitive_identifier TO on; --Amazon Redshift preserves case for column names and other identifiers. --Create a table with two columns that are identical except for the case. CREATE TABLE t ("c" int, "C" int); INSERT INTO t VALUES (1, 2); SELECT * FROM t; c | C ---+--- 1 | 2 (1 row) SET enable_case_sensitive_identifier TO off; --Amazon Redshift no longer preserves case for column names and other identifiers. SELECT * FROM t; c | c ---+--- 1 | 1 (1 row)
  • We recommend that regular users querying tables with dynamic data masking or row-level security policies attached have the default enable_case_sensitive_identifier setting. For information on row-level security, see Row-level security. For information on dynamic data masking, see Dynamic data masking.