cancel
Showing results for 
Search instead for 
Did you mean: 

Identifly keys and table types

david_bieber
New Contributor
Hi,

I have a couple of questions which I hope someone might be able to help me with

1) Is there a way to identify the names of columns that are keyed in a table? 

tmem:([dt:`date$ 2014.02.13 2014.02.14];bid:`float$1.283 1.387)
meta tmem
c  | t f a
---| -----  
dt | d    
bid| f 

I can see in this example the data type but no definition that dt is keyed.

2) Is there a way to identify a table that is splayed? I can use .Q.qp to identify a partitioned table but I don't anyway to identify a splayed and non splayed tables

tmem:([]dt:`date$ 2014.02.13 2014.03.13;bid:`float$1.283 1.387)
.Q.pq tmem
 0b

`:c:/q/splay/tsplay/ set tmem
\l c:/q/splay
.Q.qp tsplay
 0b
 
This information is useful for some python classes I am writing to automatically insert data into a normal, splayed or partitioned tables.

Many thanks

David
5 REPLIES 5

pawel_tryfon
New Contributor
Ad.1: Knowing that t is a keyed table (99h=type t) you can do cols key t.
Ad.2: .Q.qp function reference says 1b if given a partitioned table, 0b if given a splayed table, and 0 for anything else.

HTH,
Pawel Tryfon



2014-02-18 10:07 GMT+01:00 David Bieber <david.bieber@gmail.com>:
Hi,

I have a couple of questions which I hope someone might be able to help me with

1) Is there a way to identify the names of columns that are keyed in a table? 

tmem:([dt:`date$ 2014.02.13 2014.02.14];bid:`float$1.283 1.387)
meta tmem
c  | t f a
---| -----  
dt | d    
bid| f 

I can see in this example the data type but no definition that dt is keyed.

2) Is there a way to identify a table that is splayed? I can use .Q.qp to identify a partitioned table but I don't anyway to identify a splayed and non splayed tables

tmem:([]dt:`date$ 2014.02.13 2014.03.13;bid:`float$1.283 1.387)
.Q.pq tmem
 0b

`:c:/q/splay/tsplay/ set tmem
\l c:/q/splay
.Q.qp tsplay
 0b
 
This information is useful for some python classes I am writing to automatically insert data into a normal, splayed or partitioned tables.

Many thanks

David

--
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.

keys <table name>

Should give you the list of primary key col names

Perfect thanks

david_bieber
New Contributor
I have just realized how to answer my first question

cols (key tmem)
`dt

cols (value tmem)
`bid


David

or simply keys tmem