Showing results for 
Search instead for 
Did you mean: 

How to create table from API?

New Contributor

I saw multiple examples how to insert/bulk insert or query kdb+ via Java c (API), but unable to find single reference how to create table.

What I tried:
c.k("TableName:([]time:`time$())"); // returns null

Any help would be greatly appreciated.


P.S. I don't understand the existing current JavaDoc ...

Visit our website at

Privileged/Confidential information may be contained in this message and may be subject to legal privilege. Access to this e-mail by anyone other than the intended is unauthorised. If you are not the intended recipient (or responsible for delivery of the message to such person), you may not use, copy, distribute or deliver to anyone this message (or any part of its contents) or take any action in reliance on it. In such case, you should destroy this message, and notify us immediately. If you have received this email in error, please notify us immediately by e-mail and delete the e-mail from your computer. If you or your employer does not consent to internet e-mail messages of this kind, please notify us immediately. All reasonable precautions have been taken to ensure no viruses are present in this e-mail. As Algoteq Pty Ltd cannot accept responsibility for any loss or damage arising from the use of this e-mail or attachments we recommend that you subject these to your virus checking procedures prior to use. The views, opinions, conclusions and other informations expressed in this electronic mail are not given or endorsed by the company unless otherwise indicated by an authorised representative independent of this message.

New Contributor
Hi Pranas,

That command will create a table as you expect, it's just that it doesn't return anything (which you'll also see if you run that line in an interactive q session).

To create a kdb representation of a table (i.e. c.Flip), the easiest way is to create the table in terms of a dictionary:


         public static void main(String[] args) throws KException, IOException {
int[] col1 = { 1, 2, 3 };
boolean[] col2 = { true, false, true };
String[] col3 = { "sym1", "sym2", "sym3" };
String[] colNames = { "col1", "col2", "col3" };
Object[] cols = new Object[3];
cols[0] = col1;
cols[1] = col2;
cols[2] = col3;
c.Flip table = new c.Flip(new c.Dict(colNames, cols));

new c("localhost", 5007).k("func", table);


q)func:{show x}

Run the Java:

q)col1 col2 col3
1    1    sym1
2    0    sym2
3    1    sym3


I tried the example provided by you, but I get the following error:

Exception in thread "main" kx.c$KException: func
at kx.c.k(
at kx.c.k(
at kx.c.k(

Am I doing something wrong? Apart from running this on Windows?

Best Regards,

Hi Alexander,

Any KException is an kdb error that has occurred (shown in an interactive kdb session as 'error). 

In this case the error is because there is not function on the kdb process called "func". You should change this to the function you're expecting to call.