Kdb +附带内置的编程语言,称为 q .它包含标准SQL的超集,可扩展用于时间序列分析,并提供许多优于标准版本的优势.任何熟悉SQL的人都可以在几天内学习 q ,并能够快速编写自己的即席查询.
要开始使用kdb +,您需要启动 q 会话.有三种方法可以开始 q 会话 : 去;
只需输入"c:/q/w32/q.exe"在您的运行终端上.
启动MS-DOS命令终端并键入 q .
将 q.exe 文件复制到"C:\ Windows \ System32"并在运行终端上输入" q".
我们假设您正在使用Windows平台.
下表提供了支持的数据类型列表 :
名称 | 示例 | Char | 类型 | 尺寸 |
---|---|---|---|---|
boolean | 1b | b | 1 | 1 |
byte | 0xff | x | 4 | 1 |
short | 23h | h | 5 | 2 |
int | 23i | i | 6 | 4 |
long | 23j | j | 7 | 8 |
real | 2.3e | e | 8 | 4 |
float | 2.3f | f | 9 | 8 |
char | "a" | c | 10 | 1 |
varchar | `ab | s | 11 | * |
月 | 2003.03m | m | 13 | 4 |
date | 2015.03.17T18:01:40.134 | z | 15 | 8 |
分钟 | 08:31 | u | 17 | 4 |
second | 08:31:53 | v | 18 | 4 |
time | 18:03:18.521 | t | 19 | 4 |
enum | `u $`b,其中u:`a`b | * | 20 | 4 |
原子是单个实体,例如,单个数字,字符或符号.在上表(不同数据类型)中,所有支持的数据类型都是原子.列表是一系列原子或其他类型,包括列表.
将任何类型的原子传递给monadic(即单参数函数)类型函数将返回负值,即 -n ,而将这些原子的简单列表传递给type函数将返回正值 n .
/ Note that the comments begin with a slash " / " and cause the parser / to ignore everything up to the end of the line. x: `mohan / `mohan is a symbol, assigned to a variable x type x / let’s check the type of x -11h / -ve sign, because it’s single element. y: (`abc;`bca;`cab) / list of three symbols, y is the variable name. type y 11h / +ve sign, as it contain list of atoms (symbol). y1: (`abc`bca`cab) / another way of writing y, please note NO semicolon y2: (`$"symbols may have interior blanks") / string to symbol conversion y[0] / return `abc y 0 / same as y[0], also returns `abc y 0 2 / returns `abc`cab, same as does y[0 2] z: (`abc; 10 20 30; (`a`b); 9.9 8.8 7.7) / List of different types, z 2 0 / returns (`a`b; `abc), z[2;0] / return `a. first element of z[2] x: "Hello World!" / list of character, a string x 4 0 / returns "oH" i.e. 4th and 0th(first) element