Actions6
- Database Actions
Overview
This node provides functionality to delete data or entire tables from a database. It supports three main deletion commands:
- Truncate: Removes all data from a specified table but keeps the table structure intact.
- Delete: Deletes rows matching specified conditions; if no conditions are provided, it deletes all rows in the table.
- Drop: Permanently deletes both the data and the table structure.
This node is useful when you need to clean up data selectively or completely remove tables as part of database maintenance, data migration, or automation workflows. For example, you might use it to clear out old log entries (using Delete with conditions), reset a staging table (using Truncate), or remove obsolete tables (using Drop).
Properties
| Name | Meaning |
|---|---|
| Table | The target table to operate on. Can be selected from a list of available tables or specified by name. |
| Command | The type of delete operation to perform: - Truncate: Remove all data but keep table structure. - Delete: Delete rows matching conditions or all rows if none specified. - Drop: Delete table and its structure. |
| Select Rows | Conditions to select which rows to delete when using the Delete command. Multiple conditions can be combined. If not set, all rows will be deleted. |
| Combine Conditions | How to combine multiple row selection conditions: - AND: All conditions must be true. - OR: At least one condition must be true. |
| Options | Additional options for the operation: - Connection Timeout (ms): Time allowed to connect to the database. - Connections Limit: Max simultaneous connections. - Query Batching: How queries are sent (single, independent, transaction). - Other advanced options related to query execution and output formatting. |
Output
The node outputs JSON data containing details about the executed operation:
- When detailed output is enabled, it includes the executed query, query type, debug information, number of affected rows, and raw results.
- Otherwise, it returns confirmation of success and any relevant result data.
- The output is structured per input item, allowing batch processing.
- No binary data output is indicated.
Dependencies
- Requires connection to a MySQL-compatible database.
- Needs appropriate credentials (API key or authentication token) configured in n8n to access the database.
- Relies on internal methods for listing tables and columns to populate dropdowns and support dynamic expressions.
Troubleshooting
Common Issues:
- Incorrect table name or missing table selection may cause errors.
- Invalid or incomplete row selection conditions can lead to unintended deletions or no effect.
- Insufficient database permissions to delete or drop tables.
- Connection timeouts or limits exceeded due to database load or misconfiguration.
Error Messages:
- Errors related to SQL syntax or invalid commands usually indicate malformed input or unsupported operations.
- Connection errors suggest checking credentials, network access, and database availability.
- Permission denied errors require verifying user privileges on the database.
Resolutions:
- Double-check table names and ensure they exist.
- Carefully define row selection conditions to avoid deleting unintended data.
- Verify that the database user has DELETE, TRUNCATE, or DROP privileges as needed.
- Adjust connection timeout and limit settings based on environment performance.