Generate SQL DDL
AI-generatedOverview
This node, named Schema Inferrer, is designed to convert a JSON schema provided in the input into a SQL CREATE TABLE statement. It supports multiple database types such as PostgreSQL, MySQL, MariaDB, SQLite3, MSSQL, Oracle, and CockroachDB. The node is useful for users who want to automatically generate SQL DDL statements from JSON schemas, facilitating database schema creation based on JSON data structures. Practical examples include generating table creation scripts for different SQL databases from a JSON schema describing the data structure.
Use Case Examples
- Generating a PostgreSQL CREATE TABLE statement from a JSON schema describing user data.
- Creating a MySQL table definition from a JSON schema for product inventory.
Properties
| Name | Meaning |
|---|---|
| Database Type | The database type to generate SQL for, e.g., PostgreSQL, MySQL, etc. |
| Table Name | The name of the table to create in the SQL statement. |
| Primary Key Options | Configure primary key detection and specification, including auto-detection of fields named 'id' or specifying custom primary key fields. |
| Override Options | Override schema field types before SQL generation using quick or advanced rules. |
| Naming Options | Control how field names are handled in the generated SQL DDL, including lowercasing all fields and quoting identifiers. |
Output
JSON
sql- The generated SQL CREATE TABLE statement as a string.
Dependencies
- Requires an API key credential for schema inferrer configuration (optional).
Troubleshooting
- Ensure the input JSON contains a valid 'schema' property; otherwise, SQL generation will fail.
- If primary key detection does not work as expected, verify the primary key options and field names are correctly set.
- Override rules must be correctly formatted; invalid rules may cause incorrect SQL types or errors.
- Database type must be supported and correctly selected to generate valid SQL for the target database.
Links
- PostgreSQL CREATE TABLE Documentation - Reference for PostgreSQL CREATE TABLE syntax.
- MySQL CREATE TABLE Documentation - Reference for MySQL CREATE TABLE syntax.