I am trying to delete a column from a table without the loss of data so the data can be reinstated again but when the table is loaded up by q process the deleted column will not show. Obviously my code below will not work. Is there something specific to q that can do that? dir is where the table is and c is the column to be deleted.
{[dir;t;c] delete c from (` sv (dir,t),`)}
kdb+ has an easy way to "remove" a column without actually deleting the column data. If you look in the directory where your table is stored, you should be able to identify a .d
file. This is where kdb+ stores the correct order of your table columns. To remove the column, simply delete the column name from this .d
file. For example:
q)get `:test/.d
`sym`time`src`bid`ask`bsize`asize
q)
q)`:test/.d set `sym`time`src`bid`ask`bsize
`:test/.d
q)
q)test
sym time src bid ask bsize asize
--------------------------------------------------------------
AAPL 2014.04.21D08:00:00.456000000 L 25.32 25.36 8000 8500
AAPL 2014.04.21D08:00:01.387000000 O 25.32 25.35 9500 2500
AAPL 2014.04.21D08:00:10.348000000 N 25.35 25.35 8000 5000
AAPL 2014.04.21D08:00:10.532000000 L 25.33 25.37 5000 7000
AAPL 2014.04.21D08:00:15.163000000 L 25.34 25.36 10000 8000
AAPL 2014.04.21D08:00:15.847000000 N 25.32 25.36 1500 500
AAPL 2014.04.21D08:00:16.335000000 N 25.33 25.34 8500 5500
AAPL 2014.04.21D08:00:17.017000000 N 25.33 25.34 9000 2500
AAPL 2014.04.21D08:00:17.634000000 N 25.3 25.36 9500 1000
AAPL 2014.04.21D08:00:19.427000000 L 25.33 25.36 9500 5000
AAPL 2014.04.21D08:00:24.629000000 N 25.33 25.37 6000 2000
AAPL 2014.04.21D08:00:25.207000000 L 25.33 25.36 5000 2500
AAPL 2014.04.21D08:00:29.962000000 L 25.32 25.38 3500 5000
AAPL 2014.04.21D08:00:31.998000000 O 25.34 25.36 5500 4000
AAPL 2014.04.21D08:00:33.795000000 N 25.34 25.36 5000 3500
AAPL 2014.04.21D08:00:34.651000000 L 25.35 25.37 7500 6500
AAPL 2014.04.21D08:00:38.843000000 O 25.33 25.36 4000 6500
AAPL 2014.04.21D08:00:40.062000000 L 25.33 25.38 2000 9500
AAPL 2014.04.21D08:00:43.508000000 N 25.35 25.36 6500 10000
AAPL 2014.04.21D08:00:46.823000000 N 25.35 25.38 6000 7500
..
q)\l .
q)test
sym time src bid ask bsize
--------------------------------------------------------
AAPL 2014.04.21D08:00:00.456000000 L 25.32 25.36 8000
AAPL 2014.04.21D08:00:01.387000000 O 25.32 25.35 9500
AAPL 2014.04.21D08:00:10.348000000 N 25.35 25.35 8000
AAPL 2014.04.21D08:00:10.532000000 L 25.33 25.37 5000
AAPL 2014.04.21D08:00:15.163000000 L 25.34 25.36 10000
AAPL 2014.04.21D08:00:15.847000000 N 25.32 25.36 1500
AAPL 2014.04.21D08:00:16.335000000 N 25.33 25.34 8500
AAPL 2014.04.21D08:00:17.017000000 N 25.33 25.34 9000
Once removed, kdb+ will not associate the column with your table and it will not be displayed when called into memory.
Hope this helps.