Back to changelog
New
2 minute read

Oracle: Column Collations

Oracle character columns now take a collate attribute, and Atlas plans the MODIFY ... COLLATE statements that add, change, or reset it.

Atlas now manages Oracle column collations. Add a collate attribute to a character column and Atlas inspects it, diffs it, and plans the statement that applies it.

Setting a Collation

Declare the collation next to the column type:

schema.hcl
table "USERS" {  schema = schema.APP  column "NAME" {    null    = true    type    = VARCHAR2(100)    collate = "BINARY_CI"  }  column "CODE" {    null = true    type = VARCHAR2(10)  }}
atlas migrate diff
-- Add new table named "USERS"CREATE TABLE "USERS" (  "NAME" VARCHAR2(100) COLLATE BINARY_CI,  "CODE" VARCHAR2(10));

A column without collate uses the database default, so nothing is written for it. Adding a collation to one column and changing another is planned as a single MODIFY:

atlas migrate diff
-- Modify columns in table "USERS"ALTER TABLE "USERS" MODIFY (  "NAME" COLLATE BINARY_AI,  "CODE" COLLATE BINARY_CI);

Resetting a Collation

Dropping collate returns the column to the database default. Oracle has no bare MODIFY that clears a collation, so Atlas writes the default out:

atlas migrate diff
-- Modify columns in table "USERS"ALTER TABLE "USERS" MODIFY "NAME" COLLATE USING_NLS_COMP;

USING_NLS_COMP is the database default and counts as no collation at all. Spelling it out in HCL is never reported as a change, and inspection leaves it out. Collation names are compared case-insensitively, so binary_ci and BINARY_CI describe the same state.

Getting Started

Oracle support is part of Atlas Pro. Run atlas login, add collate to the columns you want to manage, and run atlas migrate diff or atlas schema apply. Oracle accepts a COLLATE clause only on a server running MAX_STRING_SIZE=EXTENDED, and otherwise fails with ORA-43929, so the dev database used for diffing has to run in that mode as well. See the Oracle HCL reference for the full list of column attributes.

featureoraclecollationcolumns