Skip to main content

Table Structure

TablePro provides a visual interface for exploring and modifying database table structures. View column definitions, indexes, foreign keys, and the DDL (CREATE TABLE statement) for any table.
Table Structure

Accessing Table Structure

To view a table’s structure:
1

Select a Table

Click on a table name in the sidebar
2

Open Structure Tab

Click the Structure tab (below the data grid)
3

Explore

Navigate between Columns, Indexes, Foreign Keys, and DDL tabs
Or right-click a table and select Show Structure.

Columns Tab

The Columns tab displays all column definitions:
Columns tab

Column Information

PropertyDescription
NameColumn name
TypeData type (VARCHAR, INT, etc.)
NullableWhether NULL values are allowed
DefaultDefault value if none specified
ExtraAdditional attributes (AUTO_INCREMENT, etc.)
KeyPrimary key (PRI), Foreign key (FOR), etc.

Copy as TSV

Right-click the structure grid to copy column definitions as TSV (tab-separated values). This is useful for pasting into spreadsheets or documentation tools.

Data Types by Database

Common MySQL data types:
CategoryTypes
NumericINT, BIGINT, DECIMAL, FLOAT, DOUBLE
StringVARCHAR, TEXT, CHAR, ENUM
Date/TimeDATE, DATETIME, TIMESTAMP, TIME
BinaryBLOB, BINARY, VARBINARY
JSONJSON

Indexes Tab

View all indexes defined on the table:
Indexes tab

Index Information

PropertyDescription
NameIndex name
ColumnsColumns included in the index
TypeBTREE, HASH, FULLTEXT, etc.
UniqueWhether the index enforces uniqueness
PrimaryWhether this is the primary key

Index Types

TypeUsage
PRIMARYPrimary key constraint
UNIQUEUnique constraint/index
INDEXRegular index for performance
FULLTEXTFull-text search (MySQL)
SPATIALGeospatial data (PostGIS)

Foreign Keys Tab

View foreign key relationships:
Foreign Keys tab

Foreign Key Information

PropertyDescription
NameConstraint name
ColumnLocal column(s)
ReferencesTarget table and column
On DeleteAction when referenced row is deleted
On UpdateAction when referenced row is updated

Referential Actions

ActionDescription
RESTRICTPrevent delete/update if referenced
CASCADEDelete/update referencing rows
SET NULLSet referencing column to NULL
SET DEFAULTSet to default value
NO ACTIONSimilar to RESTRICT (deferred check)

DDL Tab

View the CREATE TABLE statement for the table:
DDL tab

Copying DDL

  1. Open the DDL tab
  2. Select all (Cmd+A)
  3. Copy (Cmd+C)
Use DDL for:
  • Recreating tables in another database
  • Version control of schema changes
  • Documentation
  • Creating similar tables

DDL Examples

CREATE TABLE `users` (
  `id` int NOT NULL AUTO_INCREMENT,
  `email` varchar(255) NOT NULL,
  `name` varchar(100) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`),
  KEY `created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Table Metadata

Additional table information may be displayed:
PropertyDescription
EngineStorage engine (MySQL: InnoDB, MyISAM)
CollationCharacter collation
Row CountApproximate row count
Data SizeTable data size
Index SizeIndex data size
CommentTable comment/description

Modifying Structure

Structure modifications alter your database schema. Always backup important data before making changes.

Visual Structure Editor

TablePro provides a visual interface for modifying table structure directly — no SQL required:

Adding Columns

  1. Open the Structure tab > Columns
  2. Click the + button to add a new column
  3. Set column properties: name, type, nullable, default, auto-increment, comment
  4. Click Apply to preview and execute the changes

Modifying Columns

  1. Click on a column in the Columns tab
  2. Edit properties in the detail panel
  3. Changes are tracked with undo/redo support
  4. Click Apply to preview the ALTER TABLE SQL

Removing Columns

  1. Select the column to remove
  2. Click the - button or press Delete
  3. Confirm the removal
  4. Apply changes

Schema Change Preview

Before applying structure changes, TablePro shows a preview of the generated ALTER TABLE SQL. This allows you to:
  • Review the exact SQL that will be executed
  • Verify the changes match your intent
  • Cancel if the changes are not what you expected

Undo/Redo

Structure changes support full undo/redo:
  • Press Cmd+Z to undo a change
  • Press Cmd+Shift+Z to redo a change
  • Changes are tracked until applied to the database
  • See Change Tracking for details

Adding Columns via SQL

You can also add columns directly with SQL:
-- MySQL
ALTER TABLE users ADD COLUMN phone VARCHAR(20) AFTER email;

-- PostgreSQL
ALTER TABLE users ADD COLUMN phone VARCHAR(20);

-- SQLite (limited ALTER TABLE)
ALTER TABLE users ADD COLUMN phone TEXT;

Modifying Columns via SQL

-- MySQL
ALTER TABLE users MODIFY COLUMN name VARCHAR(200) NOT NULL;

-- PostgreSQL
ALTER TABLE users ALTER COLUMN name TYPE VARCHAR(200);
ALTER TABLE users ALTER COLUMN name SET NOT NULL;

-- SQLite (requires table recreation)
-- See SQLite documentation for workarounds

Dropping Columns via SQL

-- MySQL/PostgreSQL
ALTER TABLE users DROP COLUMN phone;

-- SQLite (requires table recreation)

Managing Indexes

-- Create index
CREATE INDEX idx_users_email ON users(email);

-- Create unique index
CREATE UNIQUE INDEX idx_users_username ON users(username);

-- Drop index
DROP INDEX idx_users_email ON users;  -- MySQL
DROP INDEX idx_users_email;  -- PostgreSQL

Managing Foreign Keys

-- Add foreign key
ALTER TABLE orders
ADD CONSTRAINT fk_orders_user
FOREIGN KEY (user_id) REFERENCES users(id)
ON DELETE CASCADE;

-- Drop foreign key
ALTER TABLE orders DROP FOREIGN KEY fk_orders_user;  -- MySQL
ALTER TABLE orders DROP CONSTRAINT fk_orders_user;  -- PostgreSQL

Refreshing Structure

After making schema changes:
  1. Via sidebar: Right-click the table > Refresh
  2. Via menu: View > Refresh
  3. Automatically: Changes made in TablePro refresh automatically

Best Practices

Schema Design

  1. Use appropriate data types: Choose the smallest type that fits your data
  2. Add indexes for queries: Index columns used in WHERE and JOIN
  3. Define foreign keys: Maintain referential integrity
  4. Use NOT NULL: When columns should always have values
  5. Add defaults: Provide sensible defaults for optional columns

Naming Conventions

ElementConventionExample
TablesPlural, snake_caseusers, order_items
ColumnsSingular, snake_caseuser_id, created_at
Indexesidx_table_columnsidx_users_email
Foreign Keysfk_table_referencefk_orders_user
Primary Keysid or table_idid, user_id

Performance Considerations

  1. Primary keys: Every table should have a primary key
  2. Foreign key indexes: Index foreign key columns
  3. Composite indexes: Order columns by selectivity
  4. Avoid over-indexing: Indexes slow down writes

Troubleshooting

Structure Not Loading

  1. Check database connection
  2. Verify user has permissions to view schema
  3. Refresh the connection

Missing Columns

  1. Refresh the table structure
  2. Check if column was added in a transaction not yet committed
  3. Verify you’re looking at the correct database/schema

DDL Syntax Errors

When copying DDL to another database:
  1. Check database-specific syntax differences
  2. Adjust data types for target database
  3. Remove unsupported features (e.g., MySQL ENGINE for PostgreSQL)

Next Steps