Discussion (8)1
Log in or sign up to continue

It's a bit difficult to answer this question in general. But I will try to give you some places to look at.

First Creating the databases on the terminal you would want to look at documentation for SYS.Database

so you might end up with a method or even key it in on the terminal like this

  ClassMethod createCacheDatabase(path As %String) As %Status [ Final, Private ]
#dim db as SYS.Database = ##class(SYS.Database).%New()
set db.BlockSize=8192
set db.Directory = path
set db.ExpansionSize=0
set db.ResourceName="%DB_%DEFAULT"
set db.NewGlobalCollation=5
quit db.%Save()

Now you have created you databases you need to tell cache to create a namespace using those.

The interface to do that sit's in the Config.Coniguration class. Please refer to Config.Configuration Class Documentation in the online documentation for more info about that interface.

The deprecated way was (sorry I've just reread that documentation):

What you will do is run ##class(Config.Configuration).AddNamespace(namespace,dbName,dbName) and after that maybe to some ##class(Config.Configuration).AddGlobalMapping(..)
The new interface to do a Namespace is in  Config.Namespace

  Regardless wich you want to use they are both pretty straight forward.

This is how you can create programmatically weather on terminal or from within your code a namespace, databases and the appropriate mappings.

Oh I should mention you have to be in "%SYS" NAMESPACE to be able to do this


There's also the ^DATABASE routine in %SYS for creating databases, but it provides no options for creating/managing namespaces.


 1) Create a database
 2) Edit a database
 3) List databases
 4) Delete a database
 5) Mount a database
 6) Dismount a database
 7) Compact globals in a database
 8) Show free space for a database
 9) Show details for a database
10) Recreate a database
11) Manage database encryption
12) Return unused space for a database
13) Compact free space in a database
14) Defragment globals in a database

Hello Ramya,

sorry for the confusion.

The class Config.Configuration is deprecated. so it should'n be used anmore (mentioning it, was my fault, as my samples simply came from our code base, where we still use this interface).

so assuming you have a database named TEST2 in your system you would call

do ##class(Config.Configuration).AddNamespace("TESTNAMESPACE","TEST2","TEST2")

But this is, as mentioned deprecated

The object orientated way to do this remains in Config.Namespaces. In the docimentation there are actually samples on what to do to create a new namespace using this interface.