Skip to main content

Change Tracking

TablePro uses a queue-based change tracking system that lets you make multiple edits before committing them to the database. All changes are staged locally, giving you a chance to review, undo, or discard before anything touches your data.
Change Tracking

Overview

When you edit data or modify table structure in TablePro, changes are not applied immediately. Instead, they are queued in memory and visually highlighted in the data grid. You can then commit all changes at once or discard them entirely. This approach prevents accidental data loss and gives you full control over when modifications reach the database.
Change tracking works per-tab. Each tab maintains its own independent set of pending changes, so switching between tabs preserves your edits.

Data Changes

TablePro tracks three types of data changes: cell edits (updates), row insertions, and row deletions. All lookups are O(1) using optimized hash-based data structures, so performance remains fast even with many pending changes.

Editing Cells

To edit an existing cell:
  1. Double-click the cell you want to modify
  2. Enter the new value
  3. Press Enter to confirm or Escape to cancel
Modified cells are visually highlighted in the data grid so you can see exactly what has changed.
Modified cells
If you change a value back to its original, the change is automatically removed from the queue. TablePro detects when edits cancel each other out.

Adding Rows

To insert a new row:
  1. Click the + button in the toolbar or use the keyboard shortcut
  2. A new row appears at the bottom of the data grid, marked with an insertion indicator
  3. Fill in the values for each column
  4. Columns with default values are pre-filled with DEFAULT
New rows are tracked separately from updates. You can edit cells in a newly inserted row, and those edits are folded into the insertion rather than creating separate update records.

Deleting Rows

To delete rows:
  1. Select one or more rows in the data grid
  2. Press the Delete key or click the delete button
  3. Deleted rows are marked with a deletion indicator (strikethrough style)
Deleted rows remain visible in the grid until you commit or discard, so you can undo the deletion if needed.
Batch deletion of multiple rows is tracked as a single undo action. Undoing a batch deletion restores all rows at once.

Commit & Discard

Once you have staged your changes, you can either commit them to the database or discard them.

Committing Changes

To apply all pending changes:
  1. Click the Commit button in the toolbar, or press Cmd+S
  2. TablePro generates parameterized SQL statements for all queued changes
  3. The statements are executed against the database
  4. On success, the change queue is cleared and the grid refreshes
The commit operation generates:
Change TypeSQL Generated
Cell editUPDATE ... SET column = ? WHERE pk = ?
Row insertionINSERT INTO ... (columns) VALUES (?)
Row deletionDELETE FROM ... WHERE pk = ?
UPDATE statements require a primary key on the table. If no primary key is defined, TablePro will show an error when you try to commit updates. DELETE statements can work without a primary key by matching all column values.

Discarding Changes

To revert all pending changes:
  1. Click the Discard button in the toolbar
  2. All queued changes are removed
  3. Modified cells revert to their original values
  4. Inserted rows are removed from the grid
  5. Deleted rows are unmarked
Discard also clears the undo/redo stack for the current tab.

Undo & Redo

TablePro provides a full undo/redo stack for data edits, allowing you to step backward and forward through your changes before committing.

How It Works

Every data change is pushed onto an undo stack:
  • Cell edits: Store the previous and new value
  • Row insertions: Store the row index
  • Row deletions: Store the row index and original row data
  • Batch deletions: Store all affected rows as a single action
When you undo, the action is moved to the redo stack. When you redo, it moves back to the undo stack.

Using Undo & Redo

ActionShortcut
UndoCmd+Z
RedoCmd+Shift+Z
Undo and redo are context-aware. When the SQL editor is focused, Cmd+Z undoes text edits. When the data grid is focused, it undoes data changes.

Stack Behavior

  • The undo/redo stacks are maintained per-tab
  • Committing or discarding changes clears both stacks
  • New changes after an undo clear the redo stack (standard undo behavior)

Schema Changes

TablePro also tracks changes to table structure (columns, indexes, and foreign keys) using the same queue-based approach.

Tracked Schema Operations

OperationWhat Is Tracked
Add columnNew column definition (name, type, nullable, default, etc.)
Modify columnOld and new column definitions
Delete columnColumn marked for removal
Add indexNew index definition (name, columns, type, uniqueness)
Modify indexOld and new index definitions
Delete indexIndex marked for removal
Add foreign keyNew FK definition (columns, references, actions)
Modify foreign keyOld and new FK definitions
Delete foreign keyFK marked for removal
Modify primary keyOld and new primary key columns

Visual Indicators

In the Structure tab, pending changes are shown with visual indicators:
  • New items (columns, indexes, foreign keys) are highlighted with an insertion color
  • Modified items show which fields have changed
  • Deleted items are marked with a deletion indicator

Schema Undo & Redo

Schema changes have their own undo/redo stack (separate from data changes):
  • Up to 100 undo levels
  • New actions clear the redo stack
  • Supports all schema operation types

Previewing Schema SQL

Before applying schema changes, you can preview the generated SQL:
1

Make Changes

Add, modify, or delete columns, indexes, or foreign keys in the Structure tab
2

Click Commit

Click the Commit button or press Cmd+S
3

Review SQL

A preview sheet shows all ALTER TABLE statements that will be executed
4

Apply or Cancel

Click Apply Changes to execute, or Cancel to go back and adjust
Schema Preview
You can copy individual SQL statements from the preview sheet using the copy button next to each statement.

SQL Generation

TablePro generates database-specific SQL for both data and schema changes.

Data SQL (SQLStatementGenerator)

Data changes produce parameterized statements to prevent SQL injection:
-- UPDATE with LIMIT 1 for safety
UPDATE `users` SET `name` = ? WHERE `id` = ? LIMIT 1

-- INSERT
INSERT INTO `users` (`name`, `email`) VALUES (?, ?)

-- DELETE (with PK)
DELETE FROM `users` WHERE `id` = ? OR `id` = ?

-- DELETE (without PK, matches all columns)
DELETE FROM `users` WHERE `name` = ? AND `email` = ? LIMIT 1

Schema SQL (SchemaStatementGenerator)

Schema changes produce ALTER TABLE statements with database-specific syntax:
-- Add column
ALTER TABLE `users` ADD COLUMN `phone` VARCHAR(20) NOT NULL

-- Modify column
ALTER TABLE `users` MODIFY COLUMN `name` VARCHAR(200) NOT NULL

-- Drop column
ALTER TABLE `users` DROP COLUMN `phone`

-- Add index
CREATE INDEX `idx_email` ON `users` (`email`) USING BTREE

-- Drop foreign key
ALTER TABLE `orders` DROP FOREIGN KEY `fk_orders_user`

SQL Function Support

When editing cells, TablePro recognizes common SQL functions and inserts them as literals rather than quoted strings:
FunctionDatabase
NOW()MySQL, MariaDB
CURRENT_TIMESTAMPAll
CURDATE()MySQL, MariaDB
CURRENT_DATEAll
SYSDATE()MySQL
UTC_TIMESTAMP()MySQL, MariaDB

Dependency Ordering

Schema changes are automatically sorted by dependency order before execution:
  1. Drop foreign keys (must come first to avoid constraint violations)
  2. Drop indexes
  3. Drop/modify columns
  4. Add columns
  5. Modify primary key
  6. Add indexes
  7. Add foreign keys

Keyboard Shortcuts

ActionShortcut
Commit changesCmd+S
UndoCmd+Z
RedoCmd+Shift+Z
Delete selected rowsDelete or Cmd+Delete
Edit cellEnter or double-click
Cancel editEscape

Best Practices

Review Before Committing

Always review your pending changes before committing. The visual indicators in the data grid make it easy to spot unintended edits.

Use Undo Liberally

The undo stack is cleared when you commit, so take advantage of it while editing. It costs nothing to undo and redo while you are working.

Commit Frequently

Avoid accumulating too many changes before committing. Smaller, more frequent commits are easier to verify and less risky if something goes wrong.

Preview Schema Changes

Always use the SQL preview when modifying table structure. This lets you verify the exact ALTER TABLE statements before they execute.

Backup Before Destructive Changes

When dropping columns or making other destructive schema changes, consider backing up your table first:
CREATE TABLE users_backup AS SELECT * FROM users;

Next Steps