T.keys@i(Ki, … ;n)

Read(262) Label: primary key, hash, serial byte index,

Description:

Set primary key for a table sequence or an in-memory table and create index for the table at the same time.

Syntax:

T.keys@i(Ki,…;n)

Note:

The function sets primary key Ki,... for table sequence/in-memory table T and, in the meantime, creates an index over the key. Create hash index when the function only works with @i option. 

Parameter:

Ki

Primary key, which can be one or multiple; delete all keys of T when this parameter is absent

T

A table sequence/in-memory table

n

An integer greater than 1, which is length of the hash table; its default length is the table length; cannot create a serial byte index when this parameter is present

Option:

@s

Create a serial byte index for a serial byte primary key; omit parameter n when using this option

@m

Enable parallel processing to create the index

@t

Set the last Ki parameter as the time key and create index on it

@n

Create an sequence number key

Return value:

A table sequence/in-memory table

Example:

Set key for a table sequence and create hash index:

 

A

 

1

=demo.query("select EID,NAME,DEPT,SALARY from EMPLOYEE")

 

2

=A1.keys@i(EID,DEPT;5)

Set EID and DEPT as the key of A1’s table sequence and create a hash index whose size is 5.

3

=A1.keys@im(EID,NAME)

Create index using parallel processing.

Set key for an in-memory table and create hash index:

 

A

 

1

=demo.cursor("select EID,NAME,DEPT,SALARY,HIREDATE from EMPLOYEE").memory()

 

2

=A1.keys@i(EID,DEPT;5)

Set EID and DEPT as the key of A1’s in-memory table and create a hash index whose size is 5.

3

=A1.keys@im(EID,NAME)

Create index using parallel processing.

Create indexes of others types:

 

A

 

1

=demo.query("select EID,NAME,DEPT,SALARY,HIREDATE from EMPLOYEE")

 

2

=A1.keys@in(EID)

Set EID as the key of A1’s table sequence and create an sequence number index.

3

=A1.keys@it(EID,HIREDATE)

Set EID as basic key and HIREDATE as time key for A1’s table sequence, and create index on the time key.

4

=A1.keys()

Delete all keys of A1’s table sequence as parameters are absent.

5

=A1.derive(k(EID:3):PID)

Add a serial byte field to the table sequence.

6

=A5.keys@is(PID)

Set PID as the key of A5’s table sequence and create a serial byte index.