Description:
Set a key for a table sequence.
Syntax:
T.keys(Ki,…)
Note:
The function sets Ki,… as the key of the table sequence T. The absence of the parameter will clear the key. A T.create() operation will copy the key at the same time.
Parameter:
T |
A table sequence. |
Ki |
Key name. |
Option:
@t(…,KT) |
Set the last parameter KT as the time key, and make all other parameters the basic keys. |
Return value:
Table sequence
Example:
|
A |
|
1 |
=demo.query("select EID,NAME,DEPT,SALARY,HIREDATE from EMPLOYEE order by EID asc,DEPT asc") |
|
2 |
=A1.keys(EID,DEPT) |
Set EID&DEPT fields as A1’s key. |
3 |
=A1(1).key() |
[1,R&D]. |
4 |
=A1.keys() |
Remove the key. |
5 |
=A1(1).key() |
Return null because A1 doesn’t set a key. |
6 |
=A1.keys@t(EID,DEPT,HIREDATE) |
Set EID and DEPT as A1’s basic keys and HIREDATE as time key. |
7 |
=A1.create() |
Copy the key since table sequence T has one. |
8 |
=A7.insert(0,1,"Jack","HR",3000,date("2022-03-09")) |
|
9 |
=A8(1).key() |
[1,HR]; here values of basic keys are returned. |
Related functions: