代码之家  ›  专栏  ›  技术社区  ›  quant

如何删除与搜索条件匹配的表?

  •  0
  • quant  · 技术社区  · 9 年前

    delete some_table_name from `.
    

    但是假设我有很多表,并且想删除所有以开头的表 prefix_ _suffix .

    我该怎么做?

    2 回复  |  直到 8 年前
        1
  •  1
  •   Alexander Belopolsky    9 年前

    如果您经常需要此功能,我建议您定义一个 drop 功能如下:

    q)drop:![`.;();0b;](),
    

    q)drop{x where x like"prefix_*_suffix"}tables[]
    

    drop_matching 作用

    q)drop_matching:drop{a where(a:tables[])like x}@
    

    q)drop_matching"prefix_*_suffix"
    
        2
  •  1
  •   MdSalih    9 年前

    delete (参见 here ):

    / create some tables 
    q)`a_one`a_two`b_one`b_two set\:([] x:til 10)
        `a_one`a_two`b_one`b_two
    q)tables[]
        `s#`a_one`a_two`b_one`b_two
    
    / find table names matching "a_*" and delete them from root namespace
    q)![`.;();0b;{x where x like "a_*"} tables[]]
        `.
    q)tables[]
        `s#`b_one`b_two
    
    推荐文章