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.
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:
- Double-click the cell you want to modify
- Enter the new value
- 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.
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:
- Click the + button in the toolbar or use the keyboard shortcut
- A new row appears at the bottom of the data grid, marked with an insertion indicator
- Fill in the values for each column
- 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:
- Select one or more rows in the data grid
- Press the
Delete key or click the delete button
- 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:
- Click the Commit button in the toolbar, or press
Cmd+S
- TablePro generates parameterized SQL statements for all queued changes
- The statements are executed against the database
- On success, the change queue is cleared and the grid refreshes
The commit operation generates:
| Change Type | SQL Generated |
|---|
| Cell edit | UPDATE ... SET column = ? WHERE pk = ? |
| Row insertion | INSERT INTO ... (columns) VALUES (?) |
| Row deletion | DELETE 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:
- Click the Discard button in the toolbar
- All queued changes are removed
- Modified cells revert to their original values
- Inserted rows are removed from the grid
- 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
| Action | Shortcut |
|---|
| Undo | Cmd+Z |
| Redo | Cmd+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
| Operation | What Is Tracked |
|---|
| Add column | New column definition (name, type, nullable, default, etc.) |
| Modify column | Old and new column definitions |
| Delete column | Column marked for removal |
| Add index | New index definition (name, columns, type, uniqueness) |
| Modify index | Old and new index definitions |
| Delete index | Index marked for removal |
| Add foreign key | New FK definition (columns, references, actions) |
| Modify foreign key | Old and new FK definitions |
| Delete foreign key | FK marked for removal |
| Modify primary key | Old 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:
Make Changes
Add, modify, or delete columns, indexes, or foreign keys in the Structure tab
Click Commit
Click the Commit button or press Cmd+S
Review SQL
A preview sheet shows all ALTER TABLE statements that will be executed
Apply or Cancel
Click Apply Changes to execute, or Cancel to go back and adjust
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:
MySQL/MariaDB
PostgreSQL
SQLite
-- 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
-- UPDATE with positional parameters
UPDATE "users" SET "name" = $1 WHERE "id" = $2
-- INSERT
INSERT INTO "users" ("name", "email") VALUES ($1, $2)
-- DELETE (with PK)
DELETE FROM "users" WHERE "id" = $1 OR "id" = $2
-- UPDATE
UPDATE "users" SET "name" = ? WHERE "id" = ?
-- INSERT
INSERT INTO "users" ("name", "email") VALUES (?, ?)
-- DELETE
DELETE FROM "users" WHERE "id" = ? OR "id" = ?
Schema SQL (SchemaStatementGenerator)
Schema changes produce ALTER TABLE statements with database-specific syntax:
MySQL/MariaDB
PostgreSQL
SQLite
-- 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`
-- Add column
ALTER TABLE "users" ADD COLUMN "phone" VARCHAR(20) NOT NULL
-- Modify column (multiple statements)
ALTER TABLE "users" RENAME COLUMN "name" TO "full_name";
ALTER TABLE "users" ALTER COLUMN "full_name" TYPE VARCHAR(200);
ALTER TABLE "users" ALTER COLUMN "full_name" SET NOT NULL
-- Drop column
ALTER TABLE "users" DROP COLUMN "phone"
-- Add index
CREATE INDEX "idx_email" ON "users" ("email")
-- Drop constraint
ALTER TABLE "orders" DROP CONSTRAINT "fk_orders_user"
-- Add column
ALTER TABLE "users" ADD COLUMN "phone" TEXT
-- Drop column
ALTER TABLE "users" DROP COLUMN "phone"
-- Add index
CREATE INDEX "idx_email" ON "users" ("email")
SQLite has limited ALTER TABLE support. Modifying columns and dropping foreign keys require table recreation, which is not currently supported in the visual editor. Use the SQL editor for these operations.
SQL Function Support
When editing cells, TablePro recognizes common SQL functions and inserts them as literals rather than quoted strings:
| Function | Database |
|---|
NOW() | MySQL, MariaDB |
CURRENT_TIMESTAMP | All |
CURDATE() | MySQL, MariaDB |
CURRENT_DATE | All |
SYSDATE() | MySQL |
UTC_TIMESTAMP() | MySQL, MariaDB |
Dependency Ordering
Schema changes are automatically sorted by dependency order before execution:
- Drop foreign keys (must come first to avoid constraint violations)
- Drop indexes
- Drop/modify columns
- Add columns
- Modify primary key
- Add indexes
- Add foreign keys
Keyboard Shortcuts
| Action | Shortcut |
|---|
| Commit changes | Cmd+S |
| Undo | Cmd+Z |
| Redo | Cmd+Shift+Z |
| Delete selected rows | Delete or Cmd+Delete |
| Edit cell | Enter or double-click |
| Cancel edit | Escape |
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