Value too long for type character varying or type numeric
PostgreSQL
Value too long for type character varying or type numeric
CREATE TABLE customers
(
id numeric NOT NULL DEFAULT
nextval('seq_customers'::regclass),
first_name character varying(50),
last_name character varying(50),
account_id numeric(5),
type character varying(2),
reg_date timestamp without time zone DEFAULT now(),
CONSTRAINT customers_pkey PRIMARY KEY (id)
);
Value too long for type character varying
INSERT INTO customers
(first_name, last_name, type)
VALUES ('SCOTT', 'TIGER', 'ABCD');
ERROR: value too long for type character varying(2)
The correct insert is:
INSERT INTO customers
(first_name, last_name, type)
VALUES ('SCOTT', 'TIGER', 'AB');
Value too long for type numeric
INSERT INTO customers
(first_name, last_name, account_id)
VALUES ('SCOTT', 'TIGER', '1234567');
ERROR: value too long for type numeric(5)
The correct insert is:
INSERT INTO customers
(first_name, last_name, account_id)
VALUES ('SCOTT', 'TIGER', '12345');