Re: Set Primary key on Empty Table

To add to this, casting within the empty table will only allow one entry to be added. A way around this is to avoid casting within your empty table. Then whenever you add data to each column it will take the type of the first element entered, this will be shown below:

q)t:([deptno:()] dname:();location:())

q)`t insert (23i;"c";"d")
,0
q)t
deptno| dname location
------| -------------
23  <wbr style='"box-sizing:' inherit>  <wbr style='"box-sizing:' inherit>| c  <wbr style='"box-sizing:' inherit>  <wbr style='"box-sizing:' inherit> d<br style='"box-sizing:' inherit>q)meta t<br style='"box-sizing:' inherit>c  <wbr style='"box-sizing:' inherit>  <wbr style='"box-sizing:' inherit>  <wbr style='"box-sizing:' inherit>| t f a<br style='"box-sizing:' inherit>-------| -----<br style='"box-sizing:' inherit>deptno | i<br style='"box-sizing:' inherit>dname  <wbr style='"box-sizing:' inherit>| c<br style='"box-sizing:' inherit>loction| c</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

Using meta shows that each column has taken the type of the value added. It is essential here that the values added to each column are of the correct type. 

As a note of warning, creating untyped schemas should only be done if there is absolute certainty in the nature of incoming data.

q)t:([deptno:()] dname:();location:())q)t insert (23i;ā€œcā€;ā€œā€),0q)t insert (24i;"c";"a"),1q)meta tc | t f a--------| -----deptno | idname | clocation| C

In this simple example, the nature of the table has been changed, which could impact further processing