Description:
Create one or multiple non-primary-key-based indexes for an in-memory table.
Syntax:
T.index(I:h,w;C,…)
Note:
Treat column(s) C,… as the key and create index I for records meeting condition w , which can be omitted, on the key. When parameter h is present, create a hash index whose length is h.
The function creates one or multiple non-primary-key-based indexes for in-memory table T during creating a cursor.
Parameter:
T |
An in-memory table |
I |
Index name |
w |
Filtering condition; read the whole set when it is absent |
C |
The field(s) on which index is created |
h |
Index length |
Return value:
An in-memory table
Example:
|
A |
|
1 |
=demo.cursor("select * from SCORES ") |
|
2 |
=file("SCORES_ClassTwo.ctx") |
Create a composite table file. |
3 |
=A2.create@y(#CLASS,#STUDENTID,SUBJECT,SCORE) |
Create the composite table’s base table, where CLASS,#STUDENTID is the composite table’s key. |
4 |
=A3.append@i(A1) |
Append data of A1’s cursor to the base table. |
5 |
=A4.memory() |
Generate an in-memory table. |
6 |
=A5.index(index1:10,CLASS =="Class one";SCORE) |
Create a non-primary-key-based index named index1 for A5’s in-memory table. |