Table structure and Unicode
Structure changes need a saved session with Allow write, read again at every step and only
while the session points to the host, port and login of the open tab. Without it the Structure
view shows Read-only:
Editing a table
Section titled “Editing a table”Structure → Edit opens a draft with five sections. Nothing is sent until the review.
| Section | Fields |
|---|---|
| Columns | Order (up / down), Name, Type (with suggestions), Uns. (UNSIGNED), Zf. (ZEROFILL), Null, Default (none, NULL, value, expression; as on server for a default kept from the catalog), On upd. (ON UPDATE CURRENT_TIMESTAMP, time types only), AI (AUTO_INCREMENT), Generated (no, VIRTUAL, STORED + expression), Charset, Collation (text types), Inv. (INVISIBLE, when the server supports it), Comment; + adds a column below, the bin drops it. |
| Indexes | Name, Kind (PRIMARY, UNIQUE, INDEX, FULLTEXT, SPATIAL), columns with prefix length (len) and DESC (where supported), Invisible (MySQL 8) / Ignored (MariaDB 10.6), Comment. |
| Foreign keys | Name, column pairs (column → referenced column), referenced database and table, ON DELETE, ON UPDATE. |
| Checks | Name, Expression, Enforced (MySQL only). Needs MySQL 8.0.16+ or MariaDB 10.2.1+. Column-level checks are shown, not edited. |
| Options | Engine, Default character set, Default collation, ROW_FORMAT, AUTO_INCREMENT, Comment. Partitions are shown read-only in the Structure view. |
KryoDesk sends the desired definition; Rust compares it with the catalog read when you prepare and builds only the differences. Rules:
- Types only in documented forms, checked per server and version (
VARCHAR(255),DECIMAL(10,2),ENUM('a','b'), …). - Literals (defaults, comments, ENUM members):
'doubled,\doubled unless the session’ssql_modehasNO_BACKSLASH_ESCAPES(read at prepare time and checked again at send time); control characters other than tab and LF are refused. - Generated columns and CHECK take an expression as typed. It must be one closed expression (quotes
closed, parentheses balanced, no
;,--,#or/*outside quotes) and is always put in parentheses. - A column or index the editor cannot restate shows a lock: SRID, an unknown attribute in
EXTRA, a column-level CHECK (MariaDB, other thanjson_valid), a type outside the grammar, an ENUM/SET member with a backslash, a functional index part,USING HASH. It can be kept or dropped, not changed; other changes go through the query editor. - Column positions:
FIRST/AFTERonly for columns whose predecessor changed. - A foreign key or CHECK dropped and added under the same name goes into a second
ALTER TABLE(the server refuses the name twice in one). A change of index visibility alone isALTER INDEX … VISIBLE / INVISIBLE(MariaDBNOT IGNORED / IGNORED); enforcement alone isALTER CHECK.
Review and send
Section titled “Review and send”Review SQL… shows the exact statements (Statement or n statements, in this order, Copy), the session statements around them (Around it: …) and warnings:
- Column
xis dropped with its data. - type change: values that do not fit are cut or refused, depending on sql_mode;
- character set change: characters the new set lacks become ?;
- NOT NULL on a nullable column: existing NULLs make the statement fail in strict mode;
- the table size and row estimate, with a note that a rebuild holds a metadata lock.
| Option | Values | Effect |
|---|---|---|
| ALGORITHM | (not set), DEFAULT, INSTANT (only where the server has it), INPLACE, COPY | Added to the ALTER TABLE; a server that cannot honour it refuses with its error code instead of choosing a slower way. |
| LOCK | (not set), DEFAULT, NONE, SHARED, EXCLUSIVE | As above. |
| lock_wait_timeout | seconds, empty = server value | SET SESSION lock_wait_timeout = n for these statements (previous value restored); how long to wait for the table’s metadata lock. Not set behind ProxySQL. |
Changing an option rebuilds the statement. Send runs on the tab’s connection:
SET SESSION TRANSACTION READ WRITE;SET SESSION lock_wait_timeout = 30; -- when setSET SESSION max_statement_time = 0; -- MariaDB, when the server has itALTER TABLE `shop`.`customers` …; -- the statements shown, text protocolSET SESSION TRANSACTION READ ONLY; -- then the session checkThe first error stops the rest (Not sent (an earlier statement failed)); each statement shows
OK in n ms, n affected or its error and warnings. One statement may run up to 4 hours; the
connection’s other views wait meanwhile. Before preparing and before sending, the structure is
compared with the one loaded (SHA-256 of the definition): a change by someone else stops it with
the structure of db.table changed on the server since it was loaded. A prepared change is bound to
the connection (CONNECTION_ID()), held 5 minutes and sent once. After success the Databases tree
and open Structure views reload.
New, rename, duplicate
Section titled “New, rename, duplicate”| Menu entry | Dialog | Statement |
|---|---|---|
| New table… (database) | Table name and the same editor (starts with collation = server default for utf8mb4) | CREATE TABLE; the new table opens in Structure |
| Rename… (table, or Structure view) | Database, New name | RENAME TABLE `db`.`a` TO `db2`.`b`. Warning: views, routines, events and application code that use the old name stop working; table-level GRANTs stay on the old name; triggers move within one database, to another the server refuses (1435). |
| Duplicate structure… / Duplicate… | Database, New name (default <table>_copy) |
CREATE TABLE … LIKE …: columns, indexes, CHECK and options; no rows, foreign keys, triggers or grants. |
utf8mb4
Section titled “utf8mb4”Convert to utf8mb4… (table menu, or utf8mb4… in the Structure view) asks for a
Collation from the server’s utf8mb4 collations and builds
ALTER TABLE … CONVERT TO CHARACTER SET utf8mb4 COLLATE …. The review lists what KryoDesk
computes from the catalog:
| Check | Limit / outcome |
|---|---|
| Index column length | 4 bytes per character. 767 bytes per index column for ROW_FORMAT COMPACT / REDUNDANT, otherwise the statement fails with 1071; the warning names the prefix that fits. |
| Whole key | 3072 bytes for InnoDB DYNAMIC / COMPRESSED, 1000 for MyISAM (1071). |
| Row size | Over 65,535 bytes (CHAR/VARCHAR at 4 bytes per character) fails with 1118. |
| TEXT types | TEXT can become MEDIUMTEXT, MEDIUMTEXT LONGTEXT (room for the same number of characters). |
| Columns with their own character set | Converted too (codes or hashes kept as ascii/latin1 take up to 4× more room in indexes). |
_bin collations |
Comparisons follow the new collation’s case/accent rules. |
| Unique keys over text | Values may compare equal under the new collation; a duplicate stops the statement with 1062 and nothing changes. |
| Foreign keys (both directions) | Both tables must use the same character set and collation; otherwise MySQL error 3780 / MariaDB errno 150. |
| FULLTEXT | Rebuilt. |
| Size and time | CONVERT copies the table (ALGORITHM=COPY; INPLACE / INSTANT are refused with 1846), needs free disk space of about the table size; with LOCK=SHARED writes wait for the whole copy. Rough time at 20–100 MiB/s, plus index builds. Partitioned tables: every partition is copied. |
Default character set… (database menu) and utf8mb4 overview… (database menu) read the
database’s tables and columns that are not utf8mb4 (n of m tables not fully utf8mb4), with
table collation, number of columns, size and Convert… per table, and a list of the columns.
With Allow write, the character set and collation selects and Change database default…
(or Review SQL…) build ALTER DATABASE … CHARACTER SET … COLLATE …, which changes only the
default for new tables (and new columns without their own).