September 30th, 2008

NATIONAL CHARACTER Data

Posted by admin in F. Data Types

Many languages, such as English, Russian, Chinese, and Greek, have different characters in their alphabet. If English is the default language on your computer, the English character set contains only 255 different characters and can’t be used for Russian, Chinese, or Greek.
The NATIONAL CHARACTER set uses the code in two bytes of data for each character of the alphabet. This Unicode can encode up to about 4.3 billion characters (using UTF-32 encoding). The Unicode Consortium maintains the unicode standard. See www.unicode.org.

NATIONAL CHARACTER is the same as NATIONAL CHAR and NCHAR.

 

Example:    COL1 NATIONAL CHARACTER(20)

COL1 is a maximum of 20 double-byte characters in length.

September 29th, 2008

LONG VARCHAR(length) Data

Posted by admin in F. Data Types

This is used for a character string that has a long variable length. When you have long data that will vary greatly in length and it is important to save disk space, the LONG VARCHAR definition is used. If the maximum column length is large, and most of the time the column will be blank, then a large amount of storage can be saved.

The (length) represents an integer for the maximum length of this column definition and must be 1 or greater.
Some DBMS systems limit this to 32,767 characters and use VARCHAR for up to 255 characters.

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 stored as is. For example, if the length is set to 2000 characters and only 200 characters are entered, then the length of the data is recorded with the 200 characters of data. 

 

Example:    COL1 LONG VARCHAR(2000)

COL1 is a maximum of 2,000 characters in length.
> Long variable columns should be defined only at the end of a table.
> DB2 uses LONG VARCHAR. This option should be used only when needed and has some restrictions.
It can’t be sorted by ORDER BY, GROUP BY, DISTINCT, or UNION without the ALL option.
It can’t be in a WHERE clause except with the LIKE clause.

September 26th, 2008

VARCHAR(length) Data

Posted by admin in F. Data Types

This is used for a character string that has a variable length. When you have data that will vary greatly in length and it is important to save disk space, the VARCHAR definition is used. If the maximum column length is small, then VARCHAR is probably not a good idea. If the maximum column length is large and most of the time the column will be blank, giving an average column length that is small, then a large amount of storage can be saved.

The (length) represents an integer for the maximum length of this column definition and must be 1 or greater.
Some DBMS systems limit this to 255 characters and use LONG VARCHAR for up to 32,767 characters.

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 stored as is. For example, if the length is set to 200 characters and only 20 characters are entered, then the length of the data is recorded with the 20 characters of data.

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

 

Example:    COL1 VARCHAR(200)

COL1 is a maximum of 200 characters in length.
> Variable columns should be defined only at the end of a table.
> MySQL and SQL Server use VARCHAR.
> Oracle uses VARCHAR and VARCHAR2.

Next Page »