Help home > Tables
Tables
When you open a table or view, you can switch between three views: Definition, Data and DDL. You can also create tables in a GUI.
What you can do
| View | Contents |
|---|---|
| Definition | Columns (logical name, physical name, type, NULL, default, description), indexes and foreign keys. You can edit logical names (except in SQLite). |
| Data | Shows and edits the data in a grid. Narrow down rows with WHERE, ORDER BY or the GUI filter. |
| DDL | The SQL that creates the table, including comment definitions. For a view, the view definition. |
In the tree, double-clicking a table opens its data; double-clicking a view opens its definition. Generate SELECT opens a SELECT statement in a SQL tab, with each column commented with its logical name.
Definition
- Logical name and description: The comment is split into a logical name and a description (see Logical and physical names).
- Editing the logical name and description: Double-click a logical name or description cell (for the table itself, click "Edit" at the top) to edit the logical name and description in separate fields. Musubi SQL joins the two with the separator from the settings (its first character), so you don't type the separator yourself. In the description field, Tab inserts a tab character (Ctrl+Enter confirms). When you confirm, Musubi SQL runs the SQL that changes the comment. PostgreSQL, Oracle and SQL Server use COMMENT ON or extended properties. MySQL columns need the type to be restated, so the SQL opens in a SQL tab for you to review. SQLite has no comments, so you can't edit them there (see Logical names in SQLite).
- Foreign keys: Click a referenced table name to open that table.
Editing data
Change values, add and delete rows
Type or paste into cells (see Working with grids), click + Add Row, or select rows and click - Delete Row. NULL sets the selected cells to NULL.Review your changes
Changed cells are yellow, added rows are green (row number "+"), and rows to be deleted are red with a strikethrough (row number "×"). The footer shows "X rows with unapplied changes", Apply pulses in blue, and Revert turns red.Apply
Apply runs INSERT, UPDATE and DELETE statements, using the primary key as the condition. Revert discards all changes.
Columns you leave empty (still NULL) are left out of the INSERT, so the database fills in defaults and auto-increment values.
- Highlight: Click Highlight at the top right and type some text to highlight in yellow every cell that contains it (case-insensitive). Enter / Shift+Enter moves to the next / previous cell, and Esc clears it.
- NOT NULL, primary key and foreign key columns: NOT NULL columns get a light purple background, primary key columns light ochre and foreign key columns light teal (primary key takes precedence over foreign key, which takes precedence over NOT NULL). Turn them on or off with "NOT NULL", "Primary key" and "Foreign key" at the top right, or in the settings (shared with the SQL result grids).
Filtering
▽ Filter shows the filter panel (closing it keeps the conditions). Choose a column, a value and an operator, then click Apply or press Enter to reload. You can also add conditions by right-clicking a cell and choosing "Filter by …" or "Exclude …".
| Operator | Meaning |
|---|---|
| = ≠ > ≥ < ≤ | Compares with the value |
| contains, starts with, ends with, does not contain | Matches part of the text (% and _ act as wildcards) |
| is one of, is none of | Any of the comma-separated values |
| between | Between two values (inclusive) |
| is NULL, is not NULL | The value is missing / present |
"Match all (AND)" or "Match any (OR)" sets how conditions are combined. Unchecked conditions are ignored. The filter is combined with the WHERE box at the top using AND.
DDL
Musubi SQL builds the CREATE TABLE, comment and index SQL from the table definition, in the dialect of the selected connection (for SQLite, the CREATE statement stored in the database). Open in SQL Tab lets you edit and run it.
Creating a table in the GUI
Right-click a schema in the tree and choose "Create New Table (GUI)...", or open it from a new entity in an ER diagram.
- Enter the table name, logical name and description, and the columns (PK, logical name, physical name, data type, NOT NULL, default, auto increment, description). You can pick data types from a list.
- You can also add indexes (name, columns, unique) and foreign keys (constraint name, columns, referenced table, referenced columns).
- Add common columns: Appends the common columns (created at, updated by and so on) defined in the connection settings. Uncheck it to remove them, for tables such as logs that don't need them. If "Add common columns to new tables from the start" is on in the connection settings, they are added from the start.
- The DDL for the target database appears below as you type. Run and Create creates the table. When there is no connection (a new entity in an ER diagram), you can choose the DDL dialect.
- When opened from an ER diagram, Apply to ER Diagram updates the entity in the diagram.
Altering a table in the GUI
Right-click a table in the tree and choose "Alter Table (GUI)...", or click Alter (GUI) in the table tab. The screen is the same as Creating a table in the GUI and starts from the current definition.
- You can change a column's name, type, NOT NULL, default and logical name, add columns (green rows), drop columns, and change the primary key, indexes, foreign keys and table name.
- The ALTER statements for the difference from the original appear below as you edit. Run and Alter runs them. You are asked to confirm before columns or constraints are dropped.
- After running, Musubi SQL reloads the definition from the database, so you can keep making changes. You can also click Open in SQL Tab to review the ALTER statements and run them yourself.
Changes the database can't make with ALTER are written out as "-- " comments (in SQLite: column type, NOT NULL, default, foreign keys and primary key; in SQL Server Compact: column names; and turning auto increment on or off). In those cases, recreate the table.
Generating test data
Right-click a table in the tree and choose "Generate Test Data...". Choose a row count and a generation method for each column, and Musubi SQL INSERTs many rows at once. Use it for performance testing or checking screens.
| Method | Values |
|---|---|
| Not specified (default) | The column is left out of the INSERT, so it gets its default or auto-increment value. Auto-increment columns start with this method |
| NULL | NULL |
| Sequence | Starts at Start and increases by Step. Text columns can have a "Prefix" and "Digits" (zero-padded); for example, prefix E and 4 digits give E0001. Date columns advance one day at a time from the base date |
| Random | Numbers, dates and times between Min and Max; text is alphanumeric with the given length |
| Fixed value | The same value in every row |
| Pick from list | Picks randomly from comma-separated values (for example, Tokyo,Osaka,Nagoya; write NULL for NULL) |
| Parent table values | Picks randomly from the values in the table that the foreign key references, so parent-child relationships stay valid. For multi-column foreign keys, the values come from the same parent row |
| UUID | A random UUID |
For nullable columns, "NULL %" sets the share of NULLs. Settings are remembered per table and reused the next time you open it.
- Preview: Generates the first 10 rows and shows them (no INSERT).
- Show SQL (Don't Run): Puts the INSERT statements in a SQL tab (up to 20000 rows).
- Generate and Insert: INSERTs 1000 rows at a time. You can stop with Abort. On an error, it stops there and shows the details.
Importing data (CSV / Excel)
Right-click a table in the tree and choose "Import Data (CSV / Excel)...", or click Import... in the table tab.
- Click Choose File... and pick a CSV, TSV, text or Excel (.xlsx) file. For CSV, the encoding (UTF-8 / Shift_JIS) and delimiter are detected automatically; change them if they are wrong. For Excel, you can choose the sheet.
- For each table column, choose the file column to import. Columns whose header matches the physical or logical name are selected automatically. Columns set to "(Don't import)" are left out of the INSERT (they get their default or auto-increment value).
- Import INSERTs 1000 rows at a time. You can stop with Abort. Show SQL (Don't Run) puts the INSERT statements in a SQL tab instead.
- Thousands separators in numbers (1,000) are removed, and TRUE / FALSE and yes / no in boolean columns become 1 / 0. Empty values in numeric and date columns become NULL.
- Check "Delete existing data before importing" to delete all data in the table first.
In auto-commit mode, if an error occurs partway, the rows imported up to that point stay in the table. If you want to be able to start over, switch to manual commit before importing.
FAQ
There is no "Apply" button
You can't edit the data of views, materialized views or read-only connections.
I can't edit logical names in SQLite, or they don't appear
SQLite has no comment feature, so you can't edit them in the app. Logical names are read from line comments in the CREATE TABLE statement (-- Employee ID). See Logical names in SQLite for the format.
The row count stops partway
Only up to the maximum row count is fetched. Filter the rows, or raise the maximum row count in the settings.
▲ Back to top