# In-Memory Databases

## Overview

In addition to using tables stored on real database servers, Servoy allows you to create **In-Memory** tables (using HSQL). These tables have the same configurations as regular database tables, including column properties and events.

You can populate these In-Memory tables by using a `JSDataSet` and the `createDataSource()` function. This function allows you to dynamically define In-Memory datasources or foundsets at runtime. If you've already defined the In-Memory table in Servoy Developer, you won't need to provide the column and type information again, as this was already defined during design time.

## Creating In-Memory Databases

There are two ways to create an In-Memory database:

1. Using the [Solution Explorer](/reference/servoy-developer/solution-explorer.md) context menu under `Datasources -> In Memory -> Create new data source`. This opens a dialog where you can specify the datasource name.

<div align="left"><figure><img src="/files/esEE1usxAQpvgb5j37A1" alt=""><figcaption><p>Create In-Memory datasource</p></figcaption></figure></div>

After adding the datasource name, the [Table Editor](/reference/servoy-developer/object-editors/table-editor.md) will open, allowing you to define the structure of your table, just like any other table.

2. At runtime, using [JSDataSet::createDataSource](/reference/servoycore/dev-api/database-manager/jsdataset.md#createdatasourcename).

This function allows you to dynamically define In-Memory datasources/foundsets at runtime. Alternatively, if you've already defined the In-Memory datasource in the Developer, you won't need to provide column and type information at runtime, as it was set during design time.

## Additional Table Event: onLoad

In-Memory tables have an additional table event called **onLoad**, which is triggered when a form accesses the In-Memory datasource (i.e., when the form's datasource is set to the In-Memory table) or when [datasource.mem.name.getFoundSet()](/reference/servoycore/dev-api/database-manager/jsdataset.md#getFoundSet) is called. This event enables you to populate the In-Memory datasource on demand, rather than during the solution or form's `onLoad` event.

However, you still need to use the [JSDataSet::createDataSource()](/reference/servoycore/dev-api/database-manager/jsdataset.md#createdatasourcename) function within the **onLoad** method to actually populate the In-Memory table.

## Commands Summary

Below is a summary of available commands via the context menu for In-Memory datasources:

| Command                                                     | Summary                                                                                                |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
| [Create in memory datasource](#create-in-memory-datasource) | Opens the [Table Editor](/reference/servoy-developer/object-editors/table-editor.md)                   |
| [Edit table/view](#edit-table-view)                         | Opens the [Table Editor](/reference/servoy-developer/object-editors/table-editor.md) to edit the table |
| [Delete In Memory Datasource](#delete-in-memory-datasource) | Deletes the In-Memory Datasource definition                                                            |
| [Rename In Memory Datasource](#rename-in-memory-datasource) | Renames the In-Memory Datasource definition                                                            |
| [Search for references](#search-for-references)             | Searches for all locations within the solution where the In-Memory datasource is used                  |

## Commands Details

### Create in memory datasource

Creates an In-Memory datasource with a specified name (table name). Opens the [Table Editor](/reference/servoy-developer/object-editors/table-editor.md) to define and edit the table as you would for a regular database table.

### Edit table/view

Opens the [Table Editor](/reference/servoy-developer/object-editors/table-editor.md) to edit the In-Memory table's structure and column information (metadata stored by Servoy Developer).

### Move In Memory Datasource

Moves the In-Memory Datasource to another solution (module).

### Delete In Memory Datasource

Deletes the In-Memory Datasource definition.

### Rename In Memory Datasource

Renames the In-Memory Datasource definition.

### Search for references

Searches for all locations within the solution where the In-Memory datasource is used, and lists them in the ##Search view##. This can be useful to find out which objects are using this data source.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/guides/develop/application-design/data-modeling/in-memory-databases.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
