SQL Dialects & Portability

Type and Generated-Value Differences

Type names are not semantic guarantees: range, precision, time-zone handling, coercion, storage, comparison, and driver conversion differ. Define application domains and round-trip tests first, then map each dialect explicitly; generated values still require uniqueness constraints and safe retrieval.
  • Map domains, not spellings.
  • Exact numbers need an overflow policy.
  • Separate instants from civil time.
  • Generated values are allocation, not identity.
  • Retrieval must be statement- and scope-safe.
  • Round-trip at boundaries.
Generated integer key and safe insert result
CREATE TABLE customers (customer_id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, email varchar(320) NOT NULL UNIQUE);
INSERT INTO customers (email) VALUES ('[email protected]') RETURNING customer_id;
Type-mapping questions (verify chosen versions and drivers)
DomainPostgreSQLMySQLSQLiteSQL ServerOracle
Textvarchar/text, database encodingvarchar/text + charset/collationTEXT, dynamic typing/affinityvarchar or nvarcharVARCHAR2/NVARCHAR2/CLOB; empty string becomes null
Exact numbernumeric(p,s)decimal(p,s)NUMERIC affinity; representation can varydecimal(p,s)NUMBER(p,s)
Instanttimestamp with time zone normalizes instanttimestamp has UTC/session conversion and limited rangeno dedicated storage class; convention requireddatetimeoffsetTIMESTAMP WITH TIME ZONE
BooleanbooleanBOOLEAN synonym maps to integer type0/1 convention; TRUE/FALSE literalsbitBOOLEAN in 26ai; qualify older-version mapping
Binary/largebytea/large objectsbinary/blob familiesBLOBvarbinary(max)RAW/BLOB
JSONjson/jsonbJSON typetext/blob plus JSON functionsJSON representation/features depend versionJSON type/features depend version
UUIDuuidbinary(16) or char mappingBLOB(16)/TEXT conventionuniqueidentifierRAW(16) or character mapping