← Files SQL CopilotARCHIVED FILE

references/null-time-types.md

1.25 KB · Nov 12, 2026 · 18:42 UTC

↓ Download file

See the change to this file →

# NULL, time and type semantics

## NULLs
SQL uses three-valued logic: TRUE/FALSE/UNKNOWN. `col = NULL` does not test missingness; use `IS NULL`. In predicates, UNKNOWN is not TRUE and is filtered out. `COUNT(col)` ignores NULL, while `COUNT(*)` counts rows. An empty string is not always semantically equivalent to NULL; Oracle has distinctive behavior.

## Time
Distinguish local dates, UTC instants, timestamps without timezone, and strings that only resemble dates. `2026-11-01 01:30` is ambiguous during a fall DST transition in many zones. Prefer explicit timezone transformation and a half-open UTC interval for partition-pruning filters; derive local reporting date separately where useful.

## Types
Preserve postal codes, account identifiers, SKUs and other formatted IDs as text even when digits-only. Be wary of implicit numeric conversion, integer division, overflow, decimal scale, locale-specific formats and case-sensitive collations. Cast explicitly where required but acknowledge `SAFE_CAST`/TRY_CAST semantics differ across engines.

## Practical tests
Test a null key, zero amount, end boundary, duplicate timestamp, daylight-saving change, leading-zero code, and nonnumeric input in a cast-sensitive query. Document what outcome is intended before tuning.

SHA-256: dafc6076faf253bb1c4b3dac2114c8b5c940777a493b3004dce4c7e607b95f76