Progress
Embedded SQL-92
Guide and Reference


CREATE INDEX

The CREATE INDEX statement creates an index on one or more columns of a table. The purpose of an index is to improve the retrieval time for rows in a table. You can specify an index in ascending order (ASC) or descending order (DESC).

EXAMPLE

The index in this CREATE INDEX example is specified on the single column cust_no, and is of ascending order on the value of the column:

/* 
** CONNECT to the DEFAULT database. 
*/ 
EXEC SQL 
     CONNECT TO DEFAULT ;  
/* 
** Create the idx_cust.index.  
*/ 
EXEC SQL 
     CREATE INDEX idx_cust ON customer (cust_no ASC) ; 
if (sqlca.sqlcode < 0) 
{ 
     printf ("CREATE INDEX idx_cust statement failed (%ld : %s) \n", 
          sqlca.sqlcode, sqlca.sqlerrm);  
     EXEC SQL ROLLBACK WORK ;  
     EXEC SQL DISCONNECT DEFAULT ;  
     exit (1); 
} 
/*  
** COMMIT the CREATE INDEX operation. 
*/ 
EXEC SQL COMMIT WORK ;  
printf ("Index idx_cust created. \n");  
/* 
** DISCONNECT from the DEFAULT database  
*/ 
EXEC SQL  
     DISCONNECT DEFAULT ; 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095