September 25th, 2008

CHAR(length) Data

Posted by admin in F. Data Types

This is used for a character string that always has the same length.

The (length) represents an integer for the maximum length of this column definition and must be 1 or greater.

Alphanumeric data can be stored in this definition.

If the length of the data entered into this column is shorter than the column definition, then the data is padded with spaces to the length specified by (length). For example, if the length is set to 20 characters and only 8 characters are entered, then 12 spaces are added to the end. If the data is too long, then it will be truncated.

CHAR is the same as CHARACTER. We use CHAR in this course.

 

Example:    COL1 CHAR(30)

COL1 is 30 characters in length.

September 24th, 2008

Character String Data, Part 2 of 2

Posted by admin in F. Data Types

Character String Data is coded by the RDBMS vendors as follows:

September 23rd, 2008

Character String Data, Part 1 of 2

Posted by admin in F. Data Types

Character string data is represented by the following:> A sequence of zero or more characters.

> The length can be fixed or varying.

> In an SQL statement, it is a string of characters surrounded by single quotes.

> It is case sensitive, with upper- and lower-case letters, as well as numbers, spaces, and special characters.

 

> The length of a string is an integer, including zero. An empty string of no characters is represented by two single quotes with no space between the quotes (”). This is a zero-length string.
> If you wish to place a single quote in a data value, you do this with two single quotes, so ‘I can”t go’ means, “I can’t go.” A double-quote character (“) doesn’t need this special treatment.
> SQL can handle and sort fixed-length strings faster than variable-length strings.
> Keep column data size as small as possible, because too much volume will waste time and storage.
> SQL:1999 introduced CLOB and NCLOB, but most RDBMS systems already had similar data types.
> Oracle treats empty strings as null.
> In MySQL, if the ANSI_QUOTES option is turned on, string literals can only be quoted with single quotes and an identifier is surrounded by double quotes.

« Previous PageNext Page »