Átomo
139Dv
Restrições · SQL

DEFAULT

Abrir na tabela

Definição

Define o valor usado quando a coluna não é informada no INSERT.

Exemplos

1. Carimbo de criação
CREATE TABLE orders (
  order_id   INT,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
2. Valor fixo
CREATE TABLE customers (
  customer_id INT,
  status      VARCHAR(10) DEFAULT 'ACTIVE'
);
3. Em coluna existente (PostgreSQL)
ALTER TABLE customers
ALTER COLUMN country SET DEFAULT 'PT';

No mesmo grupo