Target table creation

Overview

Target table creation allows you to create tables directly within your selected target database and schema through Gluesync’s Core Hub interface. When setting up replication for a source table, if the corresponding table doesn’t exist in the target database, Gluesync automatically launches a table creation wizard.

The wizard generates a CREATE TABLE statement based on the source table’s structure (columns, data types, primary keys, etc.) and converts it to be compatible with the target database’s requirements. You can review, edit, and confirm the statement before execution.

When to use target table creation

  • First-time replication setup: When replicating a table that doesn’t exist in the target database yet

  • Schema migration: When you need to create target tables with the same structure as source tables

  • Cross-database replication: When moving data between different database types that require DDL adjustments

  • Automated table provisioning: When you want Gluesync to handle the initial table creation step

How it works

  1. Table discovery: When configuring replication, Gluesync checks if the target table exists

  2. Wizard activation: If the table is not found, the table creation wizard automatically appears

  3. Statement generation: Gluesync generates a CREATE TABLE statement based on:

    • Source table columns and data types

    • Primary key definitions

    • Indexes and constraints (where applicable)

    • Target database compatibility conversions

  4. Review and Edit: You can review the generated SQL and make modifications if needed

  5. Execution: Once confirmed, Gluesync executes the statement in the target database

  6. Replication Setup: After table creation, normal replication configuration continues

Table creation wizard interface

The CREATE TABLE statement is automatically adapted for target database syntax. For example, MySQL data types are converted to PostgreSQL equivalents when replicating between these systems.

Prerequisites

  • Permissions: You must have DDL (Data Definition Language) permissions on the target database

  • Database Access: The target database connection must allow table creation operations

  • Schema Selection: The target schema must be properly selected and accessible

Usage steps

  1. Configure replication: Start setting up a new replication entity in Core Hub

  2. Select source table: Choose the source table you want to replicate

  3. Choose target: Select the target database and schema

  4. Edit if needed: Modify column names, data types, or add constraints as required

  5. Table creation wizard: If the target table doesn’t exist, the wizard appears automatically

  6. Review SQL statement: Examine the generated CREATE TABLE statement

  7. Execute: Confirm and execute the statement to create the table

  8. Complete setup: Continue with the replication configuration

Table creation wizard interface

Examples

Basic table creation

When replicating a customers table from MySQL to PostgreSQL:

-- Generated CREATE TABLE statement
CREATE TABLE customers (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    email VARCHAR(255) UNIQUE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Cross-database type conversion

When replicating from SQL Server to PostgreSQL, data types are automatically converted:

-- Source: SQL Server
CREATE TABLE orders (
    order_id INT IDENTITY(1,1) PRIMARY KEY,
    customer_id INT,
    order_date DATETIME,
    total_amount DECIMAL(10,2)
);

-- Generated for PostgreSQL target:
CREATE TABLE orders (
    order_id SERIAL PRIMARY KEY,
    customer_id INTEGER,
    order_date TIMESTAMP,
    total_amount NUMERIC(10,2)
);

Adding constraints

You can modify the generated statement to add additional constraints:

CREATE TABLE products (
    product_id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    price NUMERIC(10,2) CHECK (price > 0),
    category_id INTEGER REFERENCES categories(category_id),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Best practices

  • Review generated SQL: Always examine the CREATE TABLE statement before execution

  • Test on development: Use development environments to test table creation before production

  • Plan for constraints: Consider adding foreign keys, check constraints, and indexes as needed

  • Monitor permissions: Ensure your database user has appropriate DDL permissions

  • Backup strategies: Have a rollback plan in case table creation needs to be undone

  • Naming conventions: Follow your organization’s table and column naming standards

Limitations and considerations

  • Database permissions: Requires CREATE TABLE permissions on the target database

  • Existing tables: Wizard only appears for non-existing tables; existing tables use different workflows

  • Data type compatibility: While automatic conversion is provided, complex types (e.g. custom types) may need manual adjustment

  • Foreign keys: Foreign keys constraints are not supported

  • Schema dependencies: Ensure referenced schemas and tables exist before creating dependent tables

Troubleshooting

  • Permission denied: Check that your database user has CREATE TABLE privileges

  • Syntax errors: Review the generated SQL for database-specific syntax issues

  • Connection problems: Ensure the target database connection is stable during table creation

See also