目录

Q编程语言(Q Programming Language)

Kdb +带有内置的编程语言,即q 。 它包含标准SQL的超集,可扩展用于时间序列分析,并提供许多优于标准版本的优势。 熟悉SQL的人可以在几天内学习q并能够快速编写自己的即席查询。

启动“q”环境

要开始使用kdb +,您需要启动q会话。 启动q会话有三种方法 -

  • 只需在运行终端上输入“c:/q/w32/q.exe”即可。

  • 启动MS-DOS命令终端并键入q

  • q.exe文件复制到“C:\Windows\System32”,然后在运行终端上输入“q”。

在这里,我们假设您正在使用Windows平台。

数据类型 (Data Types)

下表提供了支持的数据类型列表 -

名称 烧焦 类型 尺寸
boolean1bb11
byte0xffx41
short23hh52
int23ii64
long23jj78
real2.3ee84
float2.3ff98
char“a”c101
varchar`abs11*
month2003.03mm134
date2015.03.17T18:01:40.134z158
minute08:31u174
second08:31:53v184
time18:03:18.521t194
enum `u $`b,其中你:`a`b *204

原子和列表形成

原子是单个实体,例如,单个数字,字符或符号。 在上表(不同数据类型)中,所有支持的数据类型都是原子。 列表是原子序列或其他类型,包括列表。

将任何类型的原子传递给monadic(即单个参数函数)类型函数将返回负值,即–n ,而将这些原子的简单列表传递给type函数将返回正值n

例1 - 原子和列表形成

/ 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
↑回到顶部↑
WIKI教程 @2018