In Memory Tables · Selecting Data · Practice Question
Return a Table Without a Given Column
Question
Given a table t with a column c, return t without column c.
For example:
t:([] a:1 2 3; b:`x`y`z; c:10 20 30f)Solution
delete c from tAlternative Solution
(enlist `c) _ tExplanation
delete c from t is the idiomatic qSQL way to drop a column — it returns a copy of t with c removed, leaving every other column untouched.
_ (drop) works directly on the table's underlying column dictionary: t is internally a dictionary of column names to column values, so (enlist c) _ tdrops the key ``c `` from that dictionary, producing the same result. enlist is needed because _ expects a list of keys to drop, even when there's only one.