# Newbie questions on KDB Table

**URL:** <https://forum.kx.com/t/newbie-questions-on-kdb-table/8381>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [September 15, 2013, 7:24pm UTC](https://forum.kx.com/t/newbie-questions-on-kdb-table/8381 "2013-09-15T19:24:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![macdev21](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@macdev21](https://forum.kx.com/u/macdev21)\
**Post date:** [September 15, 2013, 7:24pm UTC](https://forum.kx.com/t/newbie-questions-on-kdb-table/8381/1 "2013-09-15T19:24:00Z")

</div>

2 newbie questions on KDB tables, stuff I could not find in q-for-mortals and kdbfaq:&nbsp;

1. When inserting into KDB table I often have columns whose values are null. For e.g. if I have columns a, b, c and d I only insert to a & b at times or a & c etc. But KDB is not letting me do that - I keep getting error. Is there a way to fix this?&nbsp;
2. How do I give a default value to a column if not explicitly inserting? This as you can see is a direct corollary of question 1.&nbsp;

Thanks!

---

<div class="post-metadata">

**Author:** ![Ryan\_Hamilton1](https://avatars.discourse-cdn.com/v4/letter/r/82dd89/32.png) [@Ryan\_Hamilton1](https://forum.kx.com/u/Ryan_Hamilton1)\
**Post date:** [September 15, 2013, 8:16pm UTC](https://forum.kx.com/t/newbie-questions-on-kdb-table/8381/2 "2013-09-15T20:16:00Z")

</div>

Hi,

Inserts where columns contain null values should work:

## q)t:( a:1 2; b:3 4.; c:`p`o) q)`t insert ([] a:1 2; c:`i`l) 2 3 q)`t insert ( a:1 2; b:1.1 2.2) 4 5 q)`t insert ( b:1.1 2.2) 6 7 q)t a b&nbsp;&nbsp; c

1 3&nbsp;&nbsp; p  
2 4&nbsp;&nbsp; o  
1&nbsp;&nbsp;&nbsp;&nbsp; i  
2&nbsp;&nbsp;&nbsp;&nbsp; l  
1 1.1  
2 2.2  
&nbsp; 1.1  
&nbsp; 2.2

Have you got an example for some code that was giving an error?

The carat^ symbol allows replacing nulls easily, for example:

## q)update 9^a, 9.99^b, `ggg^c from t a b&nbsp;&nbsp;&nbsp; c

1 3&nbsp;&nbsp;&nbsp; p  
2 4&nbsp;&nbsp;&nbsp; o  
1 9.99 i  
2 9.99 l  
1 1.1&nbsp; ggg  
2 2.2&nbsp; ggg  
9 1.1&nbsp; ggg  
9 2.2&nbsp; ggg

Either update the data as your inserting or as your retrieving.

Regards,  
Ryan

```
-- 

```

[TimeStored.com](http://TimeStored.com) - KDB+ Training, Consulting, Software

On 15/09/2013 19:24, kdb newb wrote:

> 2 newbie questions on KDB tables, stuff I could not find in q-for-mortals and kdbfaq:&nbsp;
> 
> 1. When inserting into KDB table I often have columns whose values are null. For e.g. if I have columns a, b, c and d I only insert to a & b at times or a & c etc. But KDB is not letting me do that - I keep getting error. Is there a way to fix this?&nbsp;
> 2. How do I give a default value to a column if not explicitly inserting? This as you can see is a direct corollary of question 1.&nbsp;
> 
> Thanks!
> 
> --  
> You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbplus+unsubscribe@googlegroups.com.  
> To post to this group, send email to personal-kdbplus@googlegroups.com.  
> Visit this group at http://groups.google.com/group/personal-kdbplus.  
> For more options, visit https://groups.google.com/groups/opt\_out.
