cancel
Showing results for 
Search instead for 
Did you mean: 

Set string data type

Deepak
New Contributor
Hi,

I need to set the data type for columns c3,c4 as "C" without inserting single record in table

suppose, tab is table having c3,c4 is list column
tab:([] c1:`int$(); c2:`boolean$(); c3:(); c4:())
q)meta tab    
c | t f a     
--| -----
c1| i    
c2| b   
c3|     
c4|        

I want to set c3 and c4 as "C" (string data type) with inserting a record
q)meta tab    
c | t f a    
--| -----
c1| i   
c2| b   
c3| C   
c4| C            

Please let me know how can I do this.

Thanks,
Hemant
1 REPLY 1

rahul_asati04
Contributor
Hi,
No you  can not do that. In case of table column types,the capital letters that are given by meta  like "I", "C" ,"J"  etc are not an actual datatype in kdb. They are just used to represent general list with some additional characteristics in case of tables. So if you want to convert empty list () to "C" (or "I"), basically its the conversion from general list to general list. Its only after first record you can get "C" but again kdb doesn't stops you from inserting any other type of data later in that column as also mentioned in other post. 

Example:

q) t:([]a:(1 2;3 4))
q) meta t
q) c | t f a
    a | J

q) type t`a
 q) 0h