The ksql Meta-Commands Every MySQL DBA Needs on Day One
Teams migrating from MySQL to KingbaseES or PostgreSQL lose their muscle memory for basic database inspection. These six meta-commands replace the entire `show`/`describe` workflow and surface more metadata in one shot, but the `search_path` behavior around `\dt` is a recurring gotcha that hides tables silently.
A MySQL DBA connecting to KingbaseES for the first time hits an immediate wall: `show databases` and `use db` are gone. ksql handles the same inspection tasks through client-side meta-commands — `\l` for databases, `\c` to reconnect to a different database, `\dn` to list schemas, `\dt` for tables, `\d` for table structure, and `\du` for users. None of them need a semicolon, and none are sent to the server as SQL.
The payoff is density. `\l` returns owner, encoding, and collation alongside database names, where MySQL's `show databases` gives only names. `\d` bundles column definitions, indexes, constraints, and sequence references into a single output — replacing `describe` plus `show index` plus manual constraint queries. `\du` surfaces superuser and role attributes in one column, no `mysql.user` query needed.
A trap for MySQL users is `search_path`. `\dt` without a schema prefix only shows tables in schemas on the path, which defaults to `"$user", public`. Tables in a custom schema like `app_schema` stay invisible until you either prefix with `app_schema.*` or adjust `search_path` with `set search_path to app_schema, public;`. The setting is session-local and reverts on reconnect.
ksql's meta-commands are client-side operations that query system catalogs, not SQL sent to the server — this means they work even when the database is in a restricted mode that blocks regular queries.
The `search_path` gotcha with `\dt` is the single biggest friction point for MySQL converts: tables exist but appear missing because the path doesn't include their schema. MySQL's flat database model never prepared anyone for this.
`\c` reconnecting rather than switching context in-place is a meaningful difference from `use`. It means connection pooling and session state (temp tables, prepared statements) don't survive a database switch the way they do in MySQL.
The prompt character changing from `#` to `>` based on superuser status is a small but effective safety cue — it won't stop you from running a dangerous command, but it makes privilege level visible at a glance without running any query.