19 The Paradox Driver : Create and Drop Index Statements

Create and Drop Index Statements
The Paradox driver supports SQL statements to create and delete indexes. The Create Index Primary statement is used to create primary indexes. The Create Index statement is used to create non-primary indexes. The Drop Index statement is used to delete indexes.
Create Index Primary Statement
The syntax for creating a primary index is:
CREATE [UNIQUE] INDEX PRIMARY ON
filename (column [,column...])
The UNIQUE keyword is optional; the index is unique regardless of whether you include this keyword.
filename is the name of the Paradox database file on which the index is to be based.
column is the name of a column that is included as the key field for the index. The column list must contain one or more consecutive fields in the database file, beginning with the first field in the database file.
For example:
CREATE UNIQUE INDEX PRIMARY ON emp (emp_id)
Be careful when you create a primary key because any rows that have a primary key duplication are deleted when you execute the Create Index Primary statement.
Create Index Statement
For Paradox 4.0, 4.5, and 5.0 database files, the syntax for creating a non-primary index is:
CREATE INDEX index_name
[/NON_MAINTAINED] [/CASE_INSENSITIVE] ON
filename (column [, column...])
For Paradox 7, 8, 9, and 10 database files, the syntax for creating a non-primary index is:
CREATE [UNIQUE] INDEX index_name
[/NON_MAINTAINED] [/CASE_INSENSITIVE] ON
filename [column [DESC] [,column...]
For Paradox 7, 8, 9, and 10 database files only (when the Create Type is 7, 8, 9 or 10), the optional UNIQUE keyword prevents duplicate values in the non-primary index.
index_name identifies the index. If the name contains blanks or special characters, or does not begin with a letter, surround it with the grave character ( ` ) (ASCII 96).
The NON_MAINTAINED switch makes the index non-maintained. The default is to create a maintained index.
The CASE_INSENSITIVE switch makes the index case-insensitive. The default is to create a case-sensitive index.
filename is the name of the Paradox database file on which the index is to be based.
column is the name of a column that is included as the key field for the index.
For Paradox 7, 8, 9 or 10 database files only (when the Create Type is 7, 8, 9 or 10), the DESC keyword creates a non-primary index that uses descending keys.
Drop Index Statement
The syntax for dropping a primary index is:
DROP INDEX path_name.PRIMARY
For example:
DROP INDEX emp.PRIMARY
The syntax for dropping a non-primary index is:
DROP INDEX path_name.index_name
path_name is the name of the Paradox database file from which the index is being dropped. The pathname can be either the fully qualified pathname or, if the database file is specified with the Database attribute of the connection string, a simple database file name.
index_name is the name that was given to the index when it was created. If the name contains blanks or special characters, or does not begin with a letter, surround it with the grave character ( ` ) (ASCII 96).
For example:
DROP INDEX emp.last_name