This is a quick start guide to kdb+ from Kx Systems, aimed primarily at those learning independently. It covers system installation, the q environment, q ipc, kdb+ tables and typical databases, and where to find more material. After completing this you should be able to follow the Borror tutorials Q for Mortals and Kdb+ For Mortals, and the wiki Reference and Cookbooks pages.
One caution: you can learn kdb+ reasonably well by independent study, but for serious evaluation of the product you need the help of a kdb+ consultant. This is because kdb+ is typically used for very demanding applications that require experience to set up properly. Contact Kx Systems or one of its partners for help with such evaluations.
The kdb+ system is both a database and a programming language:
- kdb+ the database (k database plus).
- q the programming language for working with kdb+
Both kdb+ and q are written in the k programming language. You do not need to know k to work with kdb+, but will occasionally see references to it. For example, q is defined in the distributed script q.k.
The Kx wiki is the best resource for learning kdb+, and includes:
- a cookbook of common tasks
- a reference on the built-in functions
- an svn repository with user and Kx contributed code.
Kx Html Pages
- the main discussion forum is the k4 listbox. This is available only to licensed customers - please use a work email address to apply for access.
- the Kdb+ Personal Developers forum is an open Google discussion group for users of the free 32-bit system.
The kx.com/q directory has various supporting files, for example the script sp.q referenced in this guide (which is also included with the free 32-bit system). These files are also copied to the svn repository, so for example, the sp.q script can also be found at kx/kdb+/sp.q.
1.4 Install Free 32-bit System
If you do not already have access to a licensed copy of kdb+, then get the 32-bit version from here. This is a complete system and ideal for learning kdb+. It is limited only by being 32-bit.
When unzipping the install, take care to retain the folder structure.
1.5 Directory Layout
The free 32-bit system is usually installed in directories:
~/q / main q directory (under the user's home) ~/q/l32 / location of linux 32-bit executable ~/q/m32 / location of mac 32-bit executable
c:\q / main q directory c:\q\w32 / location of windows 32-bit executable
It is best to install in these default directories. If you cannot do this, then define environment variable QHOME to point to the new q directory. Note that some of tutorial material assumes the default installation.
To run the system, see instructions in the next section, Q Language.
1.6 Example Files
Two sets of scripts are referenced in this guide:
1. The free 32-bit system is distributed with the following example scripts in the main directory:
- sp.q - the Suppliers and Parts sample database
- trade.q - a stock trades sample database
If you do not have these scripts, get them from kx.com/q and save in your q directory.
2. Other example files are in the svn start directory. To get these, either
download with svn, e.g.
svn export http://code.kx.com/svn/cookbook_code/start
or browse to cookbook_code, then select the Download button on the start directory
Move the start directory under your q directory, i.e. q/start. For example, there should be a file:
c:\q\start\buildhdb.q / windows ~/q/start/buildhdb.q / linux and mac
Windows users: since q source is in plain text files, it is worthwhile installing a good text editor such as notepad++ or notepad2.
When kdb+ is run, it displays a console where you can enter commands and see the results. This is all you need to follow the tutorial, and if you just want to learn a little about kdb+, then it is easiest to work in the console.
As you become more familiar with kdb+, you may try one of the GUIs:
- the most popular is Charlie Skelton's studio for kdb+, a cross-platform execution environment. It is worth having this available even if you use another interface.
- qStudio, a cross-platform IDE with charting and autocompletion by TimeStored.
- First Derivatives offer their clients the qIDE development system
- Q and K Development Tools has an eclipse plugin
- Q Insight Pad is an IDE for Windows
- Qconsole is an IDE using GTK
- PyQ let's you run kdb+ inside a Jupyter notebook.