Partager via


SET COLLATE Command

Specifies a collation sequence for character fields in subsequent indexing and sorting operations.

SET COLLATE TO cSequenceName

Parameters

  • cSequenceName
    Specifies a collation sequence. The following table lists collation sequence options that are available.

    cSequenceName

    Language

    ARABIC

    Arabic

    CZECH

    Czech

    DUTCH

    Dutch

    GENERAL

    English, French, German, Modern Spanish, Portuguese, and other Western European languages

    GERMAN

    German phone book order (DIN)

    GREEK

    Greek

    HEBREW

    Hebrew

    HUNGARY

    Hungarian

    ICELAND

    Iceland

    JAPANESE

    Japanese

    KOREAN

    Korean

    MACHINE

    Machine (the default collation sequence for earlier FoxPro versions)

    NORDAN

    Norwegian, Danish

    PINYIN

    Simplified Chinese

    POLISH

    Polish

    RUSSIAN

    Russian

    SLOVAK

    Slovak

    SPANISH

    Traditional Spanish

    STROKE

    Simplified and traditional Chinese

    SWEFIN

    Swedish, Finnish

    THAI

    Thai

    TURKISH

    Turkish

    UNIQWT

    Unique Weight

    Note

    When you specify the SPANISH option, "ch" is a single letter that sorts between "c" and "d", and "ll" sorts between "l" and "m". If you specify a collation sequence option as a literal character string, be sure to enclose the option in quotation marks:

    SET COLLATE TO "SWEFIN"
    

    MACHINE is the default collation sequence option and is the sequence FoxPro users are familiar with. Characters are ordered as they appear in the current code page. The MACHINE collation sequence provides the best performance. Using a collating sequence other than MACHINE may reduce performance primarily in comparison and indexing operations, and may create larger index files.

    GENERAL might be preferable for U.S. and Western European users. Characters are ordered as they appear in the current code page. In FoxPro versions earlier than 2.5, you might have used UPPER( ) or LOWER( ) on character fields when you created indexes. In FoxPro versions later than 2.5, you can specify the GENERAL collation sequence option and omit the UPPER( ) conversion instead.

    If you specify a collation sequence option other than MACHINE, and if you create an .idx file, a compact .idx is always created.

    Use SET("COLLATE") to return the current collation sequence.

    If you include the following line in your Visual FoxPro configuration file, a collation sequence is specified when you start Visual FoxPro:

    COLLATE = cSequenceName
    

    This is identical to issuing the following command:

    SET COLLATE TO cSequenceName
    

Remarks

SET COLLATE allows you to order tables containing accented characters for any of the supported languages. Changing the setting of SET COLLATE doesn't affect the collating sequence of previously opened indexes. Visual FoxPro automatically maintains existing indexes, providing the flexibility to create many different types of indexes, even for the same field.

For example, if an index is created with SET COLLATE set to GENERAL, and the SET COLLATE setting is later changed to SPANISH, the index retains the GENERAL collation sequence.

SET COLLATE is scoped to the current data session.

When using the SET COLLATE TO command, you may receive the error "Collating sequence <sequencename> is not found." This occurs when you attempt to use a collating sequence that is not supported by the current code page. To prevent this error, you must specify a compatible code page in your Visual FoxPro configuration file. For instance, you may see the error "Collating sequence 'CZECH' is not found" when issuing the command SET COLLATE TO 'CZECH'. To enable support for the Czech collating sequence, add the following line to your config.fpw file and restart Visual FoxPro:

CODEPAGE = 1250

For additional information on code pages and Visual FoxPro's international support, see Code Pages Supported by Visual FoxPro in Developing International Applications.

For more information on configuring Visual FoxPro, see Customizing the Visual FoxPro Environment and Special Terms for Configuration Files.

See Also

Reference

IDXCOLLATE( ) Function

SET DATASESSION Command

Code Pages Supported by Visual FoxPro

Special Terms for Configuration Files

SYS(2300) - Add or Remove Code Page

CREATE TABLE - SQL Command

ALTER TABLE - SQL Command

INDEX Command

SET Command Overview

Other Resources

Commands (Visual FoxPro)