Collection Contents Index CHAPTER 7.  SQL Data Types Numeric data types pdf/chap7.pdf

Reference Manual
   CHAPTER 7. SQL Data Types     

Character data types


Function 

For storing strings of letters, numbers and symbols.

Description 

Adaptive Server Anywhere treats CHAR, VARCHAR, and LONG VARCHAR columns all as the same type. Values up to 254 characters are stored as short strings, with a preceding length byte. Any values that are longer than 255 bytes are considered long strings. Characters after the 255th are stored separate from the row containing the long string value.

There are several functions (see SQL Functions) that will ignore the part of any string past the 255th character. They are soundex, similar, and all of the date functions. Also, any arithmetic involving the conversion of a long string to a number will work on only the first 255 characters. It would be extremely unusual to run in to one of these limitations.

All other functions and all other operators work with the full length of long strings.

Character sets and code pages 

Character data is placed in the database using the exact binary representation that is passed from the application. This usually means that character data is stored in the database with the binary representation of the current code page. The code page is the character set representation used by IBM-compatible personal computers. You can find documentation about code pages in the documentation for your operating system.

Most code pages are the same for the first 128 characters. If you use special characters from the top half of the code page (accented international language characters), you must be careful with your databases. In particular, if you copy the database to a machine that uses a different code page, those special characters will be retrieved from the database using the original code page representation. With the new code page, they will appear on the screen to be the wrong characters.

This problem also appears if you have two clients using the same multi-user server, but run with different code pages. Data inserted or updated by one client may appear incorrect to the other.

This problem also shows up if a database is used across platforms. PowerBuilder and many other Windows applications insert data into the database in the standard ANSI character set. If non-Windows applications attempt to use this data, they will not properly display or update the extended characters.

This problem is quite complex. If any of your applications use the extended characters in the upper half of the code page, make sure that all clients and all machines using the database use the same or a compatible code page.

Notes 

Data type lengths and precision of less than one are not allowed.

Compatibility 

Top of page  CHAR data type [Character]

Function 

Character data of maximum length max-length bytes.

Syntax 

{ CHAR | CHARACTER } [ ( max-length ) ]

Usage 

The default value of max-length is 1.

For strings up to 254 bytes in length, the storage requirement is the number of bytes in the string plus one additional byte. For longer strings, there is more overhead.

Strings of multi-byte characters can be held as the CHAR data type, but max-length is in bytes, not characters.

Parameters 

max-length      The maximum length in bytes of the string. The maximum size allowed is 32,767.

Standards and compatibility 

See also 

CHARACTER VARYING data type

LONG VARCHAR data type

Top of page  CHARACTER VARYING data type [Character]

Function 

Same as CHAR.

Syntax 

{ VARCHAR | CHARACTER VARYING } [ ( max-length ) ]

Usage 

The default value of max-length is 1.

For strings up to 254 bytes in length, the storage requirements are the number of bytes in the string plus one additional byte. For longer strings, there is more overhead.

Strings of multi-byte characters can be held as the CHAR data type, but it is important to note that max-length is in bytes, not characters.

Parameters 

max-length     The maximum length of the string, in bytes. The maximum size allowed is 32,767.

Standards and compatibility 

See also 

CHAR data type

LONG VARCHAR data type

Top of page  LONG VARCHAR data type [Character]

Function 

Arbitrary length character data.

Syntax 

LONG VARCHAR

Usage 

Arbitrary length strings. The maximum size is limited by the maximum size of the database file (currently 2 gigabytes).

In addition to the length of the string itself, there is some additional overhead for storage.

Standards and compatibility 

See also 

CHAR data type

CHARACTER VARYING data type

Top of page  TEXT data type [Character]

Function 

This is a user-defined data type. It is implemented as a LONG VARCHAR allowing NULL.

Syntax 

TEXT

Usage 

Arbitrary length strings. The usage is as for LONG VARCHAR.

Standards and compatibility 

See also 

LONG VARCHAR data type

Top of page  

Collection Contents Index CHAPTER 7.  SQL Data Types Numeric data types pdf/chap7.pdf