clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36228 in the last week).

CREATE TABLE customer (id SERIAL PRIMARY KEY, phone VARCHAR(20)); ALTER TABLE customer ADD CONSTRAINT CHECK(phone REGEXP '^[0-9]{3}-[0-9]{2}-[0-9]{3}$');
 hidden batch(es)


INSERT INTO customer (phone) VALUES ('123-45-678')
 hidden batch(es)


INSERT INTO customer (phone) VALUES ('123-456-789')
Check constraint 'customer_chk_1' is violated.
 hidden batch(es)


INSERT INTO customer (phone) VALUES ('123-xx-678')
Check constraint 'customer_chk_1' is violated.
 hidden batch(es)


INSERT INTO customer (phone) VALUES (' 123-45-678')
Check constraint 'customer_chk_1' is violated.
 hidden batch(es)


INSERT INTO customer (phone) VALUES ('123-45-678 ')
Check constraint 'customer_chk_1' is violated.
 hidden batch(es)


INSERT INTO customer (phone) VALUES (NULL)
 hidden batch(es)


SELECT * FROM customer
id phone
1 123-45-678
2
 hidden batch(es)