分享

kdb command

 weicat 2011-05-09
KDB+ 2.3 2006.10.09 Copyright (C) 1993-2006 Kx Systems 10/16/2006
q [f] [-p p] [-s s] [-t t] [-T T] [-o o] [-u|U u] [-w w] [-r r] [-l]
f load script (*.q), file or directory

-p port kdbc(/jdbc/odbc) http(html xml txt csv)
-s slaves for parallel execution
-t timer milliseconds
-T timeout seconds(applies to all client queries)
-o offset hours (from GMT: affects .z.Z)
-u|U usr:pwd file (if file doesn’t exist, process dies)(U=no file restrictions)
-w workspace MB limit (default: 0 unlimitied)
-r replicate from :host:port (-R sync)
-l log updates to filesystem (-L sync)
-z [0] "D" uses mm/dd/yyyy or dd/mm/yyyy
-P [7] printdigits (0:all)
-W [2] week offset (0:sat)

\a
tables
\b
views
\c [23 79]
console height,width
\d [d]
directory
\e 0|1
error trap clients
\f [d]
functions
\l [f]
load file (or dir:files splays parts scripts)
\o [0N]
offset from gmt
\p [i]
port (0 turns off)
\s [0]
slaves
\t [t]
timer set (or time expression) (1st fire after delay)
\u
reload user-password file
\v [d]
variables
\w

workspace(in-use/allocated/max/mapped; max=0 => unlimited, set by
-w)
\z [0]

"D"$ uses mm/dd/yyyy or dd/mm/yyyy
\B
invalid dependencies
\C [36 2000]
browser height,width
\P [7]
print digits(0-all)
\S [-314159]
seed
\T [0]
timeout
\W [2]
week offset(sat..fri)
\cd..
o/s commands
\\
exit
char size type literal
q
sql
java
.net
xmlschema
---------------------------------------------------------------------------------
b
1
1
0b
boolean
Boolean
boolean
boolean
x
1
4
0x0
byte
Byte
byte
byte
h
2
5
0h
short
smallint
Short
int16
short
i
4
6
0
int
int
Integer
int32
int
j
8
7
0j
long
bigint
Long
int64
long
e
4
8
0e
real
real
Float
single
single
f
8
9
0.0
float
float
Double
double
double
c
1
10
""
char
Character char
s
.
11
`
symbol
varchar
String
string
string
m
4
13
2000.01m
month
d
4
14
2000.01.01
date
date
Date
date
z
8
15
dateTtime
datetime timestamp Timestamp DateTime dateTime
u
4
17
00:00
minute
v
4
18
00:00:00
second
t
4
19
00:00:00.000 time
time
Time
TimeSpan time
*
4
20.. `s$`
enum
`char$data `CHAR$string

The int, float, char and symbol literal nulls are: 0N 0n " " `.
The rest use type extensions, e.g. 0Nd. No null for boolean or byte.
0Wd 0Wz 0Wt – placeholder infinite dates/times/datetimes (no math)

date.(year month week mm dd)
dict:`a`b!.. table:([]x:..;y:..) or +`x`y!..
time.(minute second mm ss) milliseconds=time mod 1000

Verb Infix
Prefix
s:x gets
:x idem
i+i plus
+l flip
i-i minus
-i neg
i*i times
*l first
f%f divide
%f reciprocal
a&a and
&B where
a|a or
|l reverse
a^a fill
^a null
a=a equal
=l group
a<a less
<l iasc
<s(hopen)
a>a more
>l idesc
>i(hclose)
c$a cast s$ $a string
h$a "C"$C `$C
l,l cat
,x enlist
i#l take
#l count
i_l drop
_a floor
sc(lower)
x~x match
~a not
~s(hdelete)
l!l xkey
!d key
!i (s;();S):!s
A?a find
l distinct rand([n]?bxhijefcs)
x@i at
s@ @x type
trap amend(:+-*%&|,)
x.l dot s. .d value

.sCL trap dmend(:+-*%&|,)
A bin a;a in A;a within(a;a);sC like C
{sqrt log exp sin cos tan asin acos atan}f
last sum prd min max avg

wsum wavg exit getenv
dependency::expression
Adverb

'
eachboth
each
/
[x]over
over(:+*&|,)
[x]do/while
\
[x]scan
scan(:+*&|,)
[x]do\while
':
[x]prior
prior(:-%)
/:
eachright
sv(i:i/:I s:`/:S C:c/:L) j:0x40/:X i:0x0/:X
\:
eachleft
vs(I:i\:i S:`\:s L:c\:C) X:0x40\:j X:0x0\:i
Control $[c;t;f] ?[b;t;f] if[c;..] do[n;..] while[c;..]
(:return) ('signal) @[f;x;g](trap)

comm h:<`:host:port;h"23";(-h)"a:2";>h also: h:<`:file;h 0x..
file .[`:f[/];();[:,];..] !`:d .`:d(defermap) stdout: -1".." stderr: -2".."
line f 0:L:0:f[,j,n] write/read L:w 0:L:("*BXHIJEFCSMDZUVT ";[,]delim)0:{L|f[,j,n]}
byte f 1:G:1:f[,j,n] write/read G:w 1:L:("*bxhijefcsmdzuvt ";

width)1:{G|f[,j,n]}

BNF (Expressions term Noun Verb Adverb Clauses) e:nve|te| t:n|v:tA|V
n:(<[E]>E)|{<[E]>E}|t[E:E;e|[E]]|N|{exec|select|update|delete}C<by C>
from e<where C:C,e>

parse: ([f|{}];x;,`s)
t insert x
[t;c;b;a] /select,exec
![t;c;b;a] /update,delete

parallel: dir/{date|month|year|int}/{table}/{fields}
updates can happen in background then send reset"\\l ."
.z. f(file) x(args) a(addr) h(host) u(user) w(who) s(self) zZ(gmt/local)
k(releasedate) l(license info) o(os)
b(dependencies) K(version)
.z. pg[x](get)
ps[x](set)
po[h](open)
pc[h](close) pi[x](qcon)
ph[x](http)
pp[x](http post) ts[z](timer)
vs[v;i](set) pw[u;p] (validate)
abs
aj
all
and
any
asc
asof
attr
ceiling
cols
cor
count
cov
cross
csv
cut
deltas
desc
dev
differ
distinct
each
enlist
except
fby
fills
first
flip
floor
get
group
gtime
hclose
hcount
hdel
hopen
hsym
iasc
idesc
inter
inv
key
keys
lj
load
lower
lsq
ltime
mavg
maxs
mcount
md5
mdev
med
meta
mins
mmax
mmin
mmu
mod
msum
neg
next
not
null
or
peach
pj
prds
prev
rand
rank
ratios
raze
read0
read1
reciprocal
reverse
rload
rotate
rsave
save
set
show
signum
ssr
string
sublist
sums
sv
system
tables
til
trim
txf
type
uj
ungroup
union
upper
upsert
value
var
view
views
vs
where
xasc
xcol
xcols
xdesc
xexp
xgroup
xkey
xlog
xprev
xrank
acos
asin
atan
avg
bin
by
cos
delete
do
exec
exit
exp
from
getenv
in
insert
last
like
log
max
min
prd
select
sin
sqrt
ss
sum
tan
update
wavg
where
while
within
wsum
xbar
boolean
byte
char
date
datetime
dd
float
hh
int
long
minute
mm
month
real
second
short
ss
symbol
time
week
year
types
20+ userenums
105 composition
98 table
106 f'
99 dict
107 f/
100 lambda
108 f\
101 unary prim
109 f':
102 binary prim
110 f/:
103 ternary(operator)
111 f\:
104 projection
112 dynamic load

-1!`symbol - returns `:symbol (hsym)
-2!x - returns attributes of x (attr)
-3!x - returns string representation of x (.Q.s1)
-5!x – returns parse tree for string x (-5!"select from a") (parse)
-6!x – execute parse tree (-6!-5!"select from a") (eval)
-7!`:file - returns size of file in bytes (hcount)
-8!x - returns byte representation of x
-9!x - returns x from byte representation
-11!`:file - streaming execute
-12!x - .Q.host
-13!x - .Q.addr
-15!x (md5)

abs:{x|-x}
aj:{.Q.ft[{.Q.fl[y]z 2:(x,())#y}[x;;z]]y}
all:&/
and:&
any:|/
asc:{$[99h=@x;(!x)[i]!`s#r i:<r:. x;`s#x@<x]}
asof:2:
attr:-2!
ceiling:-_-:
cols:{$[.Q.qp x:.Q.v x;.Q.pf,!+x;98h=@x;!+x;11h=@!x;!x;!+0!x]}
cor:{cov[x;y]%dev[x]*dev y}
count:#:
cov:{avg[x*y]-avg[x]*avg y:"f"$y}
cross:{n:#m:&(#x)##y;$[99=@x;((!x)[m],'n#!y)!(. x)[m],'n#. y;x[m],'n#y]}
csv:","
cut:{$[0>@x;x*!-_-(#y)%x;x]_y}
deltas:-':
desc:{$[99h=@x;(!x)[i]!r i:>r:. x;x@>x]}
dev:{sqrt var x}
differ:~~':
distinct:?:
each:{x'y}
enlist:,:
except:{x@&~x in y}
fby:{$[#y;(x[0]'x[1]@=y)y;0#x[0]x 1]}
fills:^\
first:*:
flip:+:
floor:_:
get:.:
group:=:

gtime: {t+x-%t:x+x-%x}

hclose:>:
hcount:-7!
hdel:~:
hopen:<:
hsym:-1!
iasc:<:
idesc:>:
inter:{x@&x in y}
inv:!:
key:!:
keys:{$[98h=@x:.Q.v x;0#`;!+!x]}
lj:{.Q.ft[{.Q.fl[x]y(!+!y)#x}[;y]]x}
load:{$[1=#p:`\:*|`\:x:-1!x;set[*p;. x];set[*p].h.xt[p 1]@0:x]}'
lower:_:
lsq:!
ltime:%:
mavg:{msum[x;0.0^y]%mcount[x;y]}
maxs:|\
mcount:{msum[x;~^y]}
mdev:{sqrt mavg[x;y*y]-m*m:mavg[x;y]}
med:{.5*+/x(<x)@_.5*-1 0+#x}
meta:{1!+`c`t`f`a!$[p;(v;.Q.ty@. v:.Q.pf;`;`s),';](,c),

+((.Q.ty;{$[(20>t)|77<t:@x;`;!x]};-2!)@\:x@)'c:!+x:

$[p:.Q.qp x:.Q.v x;.Q.d0[].(.+x),`;0!x]}
md5:-15!
mins:&\

mmax: {(x-1)|':/y} mmin: {(x-1)&':/y} mmu:$

mod:{x-y xbar x}
msum:{y-(-x)_(x#0**y),y:+\y}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多