Article
· Oct 6, 2016 3m read

How to dismount/mount a database programmatically

to dismount/mount a database, use Dismount() and Mount() methods in SYS.Database class available in %SYS namespace.
NB: the database ID is its Directory

You'll find  some examples of how to dismount/mount and check if a database is mounted (Mounted=1) or not (Mounted=0), and quickly see all the attributes of a database (via zwrite)


%SYS>set db="/opt/irisapp/data" 

%SYS>w ##class(SYS.Database).%OpenId(db).Mounted                     
1
%SYS>w ##class(SYS.Database).%OpenId(db).Dismount()
1
%SYS>w ##class(SYS.Database).%OpenId(db).Mounted   
0
%SYS>w ##class(SYS.Database).%OpenId(db).Mount()   
1
%SYS>w ##class(SYS.Database).%OpenId(db).Mounted
1
%SYS>zw ##class(SYS.Database).%OpenId(db)
+----------------- general information ---------------
|      oref value: 3
|      class name: SYS.Database
|           %%OID: $lb("/opt/irisapp/data","SYS.Database")
| reference count: 2
+----------------- attribute values ------------------
|       %Concurrency = 0  <Set>
|        BlockFormat = 2
|          BlockSize = 8192  <Set>
|             Blocks = 780288
|       BlocksPerMap = 62464
|   ClusterMountMode = 0  <Set>
|     ClusterMounted = 0  <Set>
|        CurrentMaps = 13
|          Directory = "/opt/irisapp/data/"  <Set>
|     DirectoryBlock = 3
|        EncryptedDB = 0  <Set>
|    EncryptionKeyID = ""
|          Expanding = 0
|      ExpansionSize = 0  <Set>
|               Full = 0
| GlobalJournalState = 3  <Get,Set>
|     InActiveMirror = 0
|  LastExpansionTime = "09/06/2023 20:00:01"
|            MaxSize = 0  <Set>
|MirrorActivationRequired = 0
|    MirrorDBCatchup = 0
| MirrorDBCreatedNew = 0
|       MirrorDBName = ""
|     MirrorDBPaused = 0
|   MirrorFailoverDB = 0
|      MirrorNoWrite = 0
|     MirrorObsolete = 0
|      MirrorSetName = ""
|           Mirrored = 0
|            Mounted = 1
| NewGlobalCollation = 5  <Set>
|NewGlobalGrowthBlock = 50  <Set>
|    NewGlobalIsKeep = 0  <Set>
|NewGlobalPointerBlock = 16  <Set>
|   NumberOfConfigDB = 0
|       ROReasonCode = 0
|       ROReasonText = ""
|           ReCreate = 0
|           ReadOnly = 0  <Set>
|    ReadOnlyMounted = 0
|       Reinitialize = 0
|        RequestSize = 0
|       ResourceName = "%DB_IRISAPP-DATA"
|RunCatchupDBOnCreate = 1
|                SFN = 6
|               Size = 6096  <Set>
|           Skeleton = 0
|           SparseDB = 0
+----------------------------------------------------- 
%SYS>
Discussion (2)1
Log in or sign up to continue