Re: Significant trailing spaces
От | Tom Lane |
---|---|
Тема | Re: Significant trailing spaces |
Дата | |
Msg-id | 10067.1091457471@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Significant trailing spaces (Steve Tucknott <steve@retsol.co.uk>) |
Список | pgsql-novice |
Steve Tucknott <steve@retsol.co.uk> writes: > I still seem to get the same problem - putting a CHAR(250) variable > (with trailing spaces) into a VARCHAR(100) gives me a VARCHAR with a > length 100 - ie padded with spaces. Is this still correct? This is per SQL specification. SQL92 section 9.2 "Store assignment" defines assignment to a varchar thusly: [ T is the target variable, V is the value being assigned ] d) If the data type of T is variable-length character string and the length in characters M of V is not greater than the maximum length in characters of T, then the value of T is set to V and the length in characters of T is set to M. e) If the data type of T is variable-length character string and the length in characters M of V is greater than the maximum length in characters L of T, then, Case: i) If the rightmost M-L characters of V are all <space>s, then the value of T is set to the first L characters of V and the length in characters of T is set to L. ii) If one or more of the rightmost M-L characters of V are not <space>s, then an exception condition is raised: data exception-string data, right truncation. If you don't want the spaces, consider using the trim() or rtrim() function. regards, tom lane
В списке pgsql-novice по дате отправления: