Default
CREATE TABLE customer
(
customer_id serial,
full_name text,
status char DEFAULT 'r',
CONSTRAINT PK_customer_customer_id PRIMARY KEY(customer_id),
CONSTRAINT CHK_customer_status CHECK (status = 'r' or status = 'p')
);
INSERT INTO customer (full_name)
VALUES
('name');
SELECT * FROM customer;
-- Drop default
ALTER TABLE customer
ALTER COLUMN status DROP DEFAULT
-- Set default
ALTER TABLE customer
ALTER COLUMN status SET DEFAULT 'r'
Last updated
Was this helpful?