Skip to content

Import and export SQL

If you already operate a SQL database, you do not need to rebuild its structure from scratch. Import its tables, columns, and indexes into a schema file (.sfn), or convert a schema file you created into SQL for an external database.


Open the SQL converter

Select the Editor tab at the top of the schema screen, then select SQL Convertor on the left.

SQL converter

Create a schema file from SQL

  • On the schema screen, select Import > SQL, then paste the CREATE TABLE statements.
  • Open a .sql file in the workspace, then run Convert to SetFN Schema.

The converter interprets common SQLite, PostgreSQL, and MySQL/MariaDB column types, defaults, auto-increment fields, indexes, and table constraints. After conversion, check the number of tables and any warnings in the .sfn document before saving it.

Select a database

Select the target database, and SQL in the selected format appears on the right.

Review the SQL script

Review the converted SQL. The following example uses MySQL.

-- MYSQL Schema creation
CREATE DATABASE IF NOT EXISTS `public`;
USE `public`;

CREATE TABLE IF NOT EXISTS `public`.`user_profile` (
    `user_id` INT AUTO_INCREMENT NOT NULL UNIQUE,
    `email` VARCHAR(255) NOT NULL UNIQUE,
    `is_active` BOOLEAN NOT NULL DEFAULT TRUE,
    `created_at` TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX `user_id_idx` ON `public`.`user_profile` (`user_id`);
CREATE INDEX `email_idx` ON `public`.`user_profile` (`email`);

Save the SQL file

Use Copy at the upper right of the code area to copy the script, or use Save to save it as a .sql file.

Supported targets

In SQL Convertor, you can select MySQL, PostgreSQL, Oracle, MSSQL, SQLite3, MongoDB, and Elasticsearch. MongoDB output is a collection creation script, and Elasticsearch output is an index mapping.

The storage engines you can deploy to WebSpace are SQLite3, PostgreSQL, MySQL, and MariaDB. SQL Convertor has no separate MariaDB option; MariaDB deployments use a MySQL/InnoDB-compatible storage format.

Good to Know

  • Generated SQL reflects the schema file's current state. Convert it again after changing the schema.
  • Some data types may not be supported by every database. Always review the conversion result.
  • Triggers, views, partitions, and stored procedures may be outside the automatic conversion scope.