VARCHAR and trailing blanks correction [CR 451561] [CR 450225]

Appendix A, “Compatibility with Other Sybase Databases” incorrectly states in the section “Character data types” that Adaptive Server Enterprise trims trailing blank spaces from VARCHAR values, but Sybase IQ does not. The correct statement is:

Adaptive Server Enterprise trims trailing blank spaces from VARCHAR values. Sybase IQ trims trailing blanks from VARCHAR values depending on the form of the data and the operation. For details, see “Character data types” in Chapter 4, “SQL Data Types.”

The following information has been added to the section “Character data types” in Chapter 4, “SQL Data types”:

VARCHAR data and trailing blanks

Data inserted via INSERT, UPDATE, or LOAD TABLE can be in one of the following forms:

For a column of data type VARCHAR, trailing blanks within the data being inserted are handled as follows:

  1. For data enclosed in quotes, trailing blanks are never trimmed.

  2. For data not enclosed in quotes:

    • Trailing blanks are always trimmed on insert and update.

    • For a LOAD statement, you can use the STRIP ON/OFF LOAD option to specify whether to have the trailing blanks trimmed. The STRIP ON/OFF option applies only to variable-length non-binary data. For example, assume the following schema:

      CREATE TABLE t( c1 VARCHAR(3) );
      LOAD TABLE t( c1 ',' ) ... STRIP ON        // trailing blanks trimmed
      
      LOAD TABLE t( c1 ',' ) ... STRIP OFF       // trailing blanks not trimmed
      
      LOAD TABLE t( c1 ASCII(3) ) ... STRIP ON   // trailing blanks not trimmed
      LOAD TABLE t( c1 ASCII(3) ) ... STRIP OFF  // trailing blanks trimmed
      
      LOAD TABLE t( c1 BINARY ) ... STRIP ON     // trailing blanks trimmed
      LOAD TABLE t( c1 BINARY ) ... STRIP OFF    // trailing blanks trimmed
      
  3. For binary data, trailing blanks are always trimmed.

You should not depend on the existence of trailing blanks in VARCHAR columns, when you write your applications. If an application relies on trailing blanks, a CHAR column should be used instead of a VARCHAR column.