On 19-09-2022 19:43, Dany40 wrote:
> Thank you to all who answered me. Following your suggestions I find this
> solution:
>
> ALTER TABLE PROC ADD SENT CHAR(8) DEFAULT ' ' NOT NULL;
> ALTER TABLE PROC ALTER COLUMN SENT POSITION 9;
> COMMIT;
> ALTER TABLE PROC ALTER COLUMN SENT DROP DEFAULT;
> COMMIT;
>
> It seems to work. BTW, when I checked the results a few selects, it
> was weird to see that select * from PROC where SENT = '' ' (8
> spaces) is returning all the records in the table, but the default was
> just ' ' (1 space).
There are two things at play here:
1) a (non-NULL) CHAR is always padded with spaces up to its declared, so
setting an empty or 1-space string on a CHAR(8) will produce a value
with 8 spaces.
2) equality of (non-NULL) string values (CHAR or VARCHAR) ignores
trailing spaces (or trailing 0x00 (NUL) bytes for OCTETS/BINARY).
Mark
--
Mark Rotteveel