kdb - deleting all records for all tables in memory in Kdb+
问题描述
I would like to delete all records for all tables in memory but still keep the schemas.
for example:
a:([]a:1 2;b:2 4);
b:([]c:2 3;d:3 5);
I wrote a function:
{[t] t::select from t where i = -1} each tables[]
this didnt work, so i tried
{[t] ![`t;enlist(=;`i;-1);0b;()]} each tables[]
didnt work either. Any idea or better ways?
解决方案
Mark 的解决方案最适合做你想做的事情,而不是功能形式。只是添加关于 t 失败的问题,因为将 kdb 代码放在注释中是很尴尬的。
您的功能形式失败不是因为t
而是因为您的最后一个参数不是符号列表`$()
。您还想删除 where i
is > -1
,而不是=
q){[t] ![t;enlist(>;`i;-1);0b;`$()]} each `d`t`q
`d`t`q
q)d
date sym time bid1 bsize1 bid2 bsize2 bid3 bsize3 ask1 asize1 ask2 asize2 ask..
-----------------------------------------------------------------------------..
q)t
date sym time src price size
----------------------------
q)q
date sym time src bid ask bsize asize
-------------------------------------
推荐阅读
- validation - 在浏览器缓存、代理缓存和源服务器的情况下,验证如何工作?
- ionic-framework - 如何获取 OneSignal 推送通知设备 ID Ionic 3
- java - Guice AssistedInject 找不到匹配的构造函数
- xamarin - Xamarin Native Android:中国推送通知
- typescript - 函数返回数组或数字时无法使用“map”方法
- angular - 为什么 ngModels 不应该直接绑定到服务变量?
- php - 为什么有时 ftp_nlist 在文件夹中有文件时返回空数组?
- jquery - 验证时显示的错误消息中的 Laravel Ajax 表单验证错误
- forms - EXTJS 4 - htmleditor 标记无效问题
- java - 功能接口eg-toString,equals中继承对象类方法有什么用