Q Language Tutorial

Posted on  by admin
  • KDB+ Architecture.
  • Q Programming Language.
  • Q Advanced Topics.
  • KDB+ Useful Resources.
  • Selected Reading.
  • Kdb+ comes with its built-in programming language that is known as q.

It incorporates a superset of standard SQL which is extended for time-series analysis and offers many advantages over the standard version.

Simple Join

Anyone familiar with SQL can learn q in a matter of days and be able to quickly write her own ad-hoc queries. To start using kdb+, you need to start the q session. There are three ways to start a q session −.

Simply type “c:/q/w32/q.exe” on your run terminal.

Start the MS-DOS command terminal and type q. Copy the q.exe file onto “C:\Windows\System32” and on the run terminal, just type “q”.

Here we are assuming that you are working on a Windows platform. The following table provides a list of supported data types −. Atoms are single entities, e.g., a single number, a character or a symbol.

Data Types

In the above table (of different data types), all supported data types are atoms. A list is a sequence of atoms or other types including lists.

Passing an atom of any type to the monadic (i.e. single argument function) type function will return a negative value, i.e., –n, whereas passing a simple list of those atoms to the type function will return a positive value n.

Union Join (uj)

KDB+ Architecture. Q Programming Language. Q Advanced Topics. KDB+ Useful Resources. Selected Reading. Tables are at the heart of kdb+. A table is a collection of named columns implemented as a dictionary.

q tables are column-oriented. Tables are created using the following syntax −.


In the above example, we have not specified the type of each column.