When configuring a Database export node, you can either export data to an existing table or create a new one. To create a new table, click the Create table button next to the table selection field. This opens a window with two tabs:
Delete existing table: If enabled, the system removes any table with the same name before creating the new one. It uses the command: DROP TABLE IF EXISTS <TableName> or an equivalent for databases that don’t support IF EXISTS.
Table name: Enter a unique name for the table. You can either type it manually or select it from the list of existing tables if you’ve enabled the Delete existing table option.
Table fields: Define the fields using these parameters:
Primary key: Specify the primary key using the syntax: CONSTRAINT <TableName>_PK PRIMARY KEY (FieldName1[... , FieldNameN]). For ClickHouse, the system uses a sort key: Engine = MergeTree() ORDER BY (FieldName1[... , FieldNameN]).
Data type: Choose from the standard data types supported by Megaladata. You can also select String(max)for the maximum possible string length.
Size (for string fields only): Set the maximum string length. The default is 50; adjust it to match your data.
Not NULL: Enforce a constraint to prevent null values in the field.
Important: If the exported string exceeds the maximum length, the system will return an error.
Use these buttons to manage the field list:
Move up/Move down: Reorder fields in the list.
Add: Insert a new field.
Edit: Open a model to edit field parameters.
All String(max): Set all string fields to String(max).
Refresh: Sync the field list with the table connected to the node's input port.
Delete all: Remove all fields from the table.
SQL query
Use this tab to view or edit the SQL query for creating the table. It offers two modes:
View mode (default): Displays the SQL query without allowing edits. Syntax highlighting is disabled, and the Execute query button is inactive. The query updates automatically based on the Table fields tab settings.
Edit mode: Allows manual editing of the SQL query. Syntax highlighting is enabled, and the Execute query button is active. The query content is independent of the Table fields tab.