Subject May a foreign key field differ in trailing spaces from its referenced field?
Author Stefan
Given the following structure:

CREATE TABLE PRUEBA1 (
CODIGO VARCHAR(10) NOT NULL
);
ALTER TABLE PRUEBA1 ADD CONSTRAINT PK_PRUEBA1 PRIMARY KEY (CODIGO);

CREATE TABLE PRUEBA2 (
CODIGO VARCHAR(10) NOT NULL,
COD_PRUEBA1 VARCHAR(10)
);
ALTER TABLE PRUEBA2 ADD CONSTRAINT PK_PRUEBA2 PRIMARY KEY (CODIGO);
ALTER TABLE PRUEBA2 ADD CONSTRAINT FK_PRUEBA2_1 FOREIGN KEY
(COD_PRUEBA1) REFERENCES PRUEBA1 (CODIGO);

Is it correct that you can insert into field PRUEBA2.COD_PRUEBA1 a value
that differs in trailing spaces from the code referenced in PRUEBA1?

Like this:

insert into prueba1 (codigo) values ('123456789 ');
insert into prueba2 (codigo, cod_prueba1) values ('COD2', '123456789');


[Non-text portions of this message have been removed]