How can I find the data type of a given table column?

Short answer: meta tablename

For example –

q)\l sp.q        / found in $QHOME/sp.q
q)s
s | name  status city
--| -------------------
s1| smith 20     london
s2| jones 10     paris
s3| blake 30     paris
s4| clark 20     london
s5| adams 30     athens
q)meta s
c     | t f a
------| -----
s     | s
name  | s
status| i
city  | s
q)

The output of meta is a kdb table, where columns c and t indicate the column name and data type, respectively.

The key the provides an alternate method:

q)key exec city from s
`symbol
q)

If you need the type code, use the type function:

q)type exec city from s
11h
q)

See also: Type character definitions, Meta output faq{.}.