export_to_sql_file
Export database schema (DDL) and data to a SQL file for migration scripts or backups. Supports objects, table data, schema dumps, and query results.
Instructions
Export schema (DDL) and/or data from the connected database to a .sql file. Supports four content kinds via the 'what' parameter: 'objects' (DDL of a list of objects), 'data' (INSERT statements for tables), 'schema_dump' (full schema, optionally with data), 'query_result' (SELECT result emitted as INSERTs into a target table). Mode is 'append' (default, appends to existing file with separator banner) or 'overwrite'. The header banner records timestamp and source server alias (host/port hidden). Use this before transfer_objects or for migration script generation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absolute or relative path to the .sql file. Must end with .sql. | |
| mode | No | File write mode. Append (default) preserves existing content with a separator banner; overwrite replaces the file. | append |
| what | Yes | ||
| include_create_if_not_exists | No | ||
| confirm_overwrite | No | When mode='overwrite' and file was modified <60s ago, set true to confirm. Foot-gun guard. | |
| server | No | One-time server override. | |
| database | No | One-time database override. | |
| schema | No | One-time schema override (sets default schema for refs). |