# TiDB

Bobby Tables connects to TiDB through the MySQL wire protocol, keeps TiDB as the saved provider, and opens each connection in a SQL workspace that follows TiDB's limits.

## Where to find it

| Action | How |
| --- | --- |
| Choose TiDB | `New connection`, `⌘N` (`Ctrl+N`), then `TiDB` under `Choose a provider` |
| Fill the form from a URL | `Use connection URL` with a `tidb://` URL, or a `mysql://` URL with port `4000` or a `tidbcloud.com` host, then `Fill fields` |
| Default port | `4000` |
URLs the app copies use `tidb://`, so change the scheme to `mysql://` for tools that only know MySQL.

## Connecting

The form asks for `Host`, `Port`, `User`, `Database (optional)` and `Password`, and notes that the connection `Uses 2 server connections`. A TiDB Cloud string with `ssl-mode=VERIFY_IDENTITY` maps to `Verify Full` in the `TLS` section, and [SSH and TLS](https://bobbytables.app/docs/ssh-and-tls) covers certificates and tunnels. `Test connection` refuses a MySQL or MariaDB server selected as TiDB. `Open in read-only mode` blocks writes in the app and disables editing, but TiDB does not enforce a read-only session, so use TiDB privileges when the server itself must refuse writes.

## What works

- Browse databases, tables, views, columns, indexes and keys in the [table grid](https://bobbytables.app/docs/table-data).
- Stage inserts, updates and deletes, then commit them in one transaction, as described in [Editing](https://bobbytables.app/docs/editing).
- Change structure in the [Structure](https://bobbytables.app/docs/structure) tab, where a change TiDB cannot make, such as adding an `AUTO_INCREMENT` column, is refused before anything is sent.
- Take a consistent [snapshot](https://bobbytables.app/docs/snapshots) that leaves out the object kinds TiDB does not support.
- Draw a [schema diagram](https://bobbytables.app/docs/schema-diagram) from declared foreign keys.
- Format result columns with [result directives](https://bobbytables.app/docs/result-directives).
- Stop a running statement with `Cancel`, `⌘.` (`Ctrl+.`), which sends `KILL QUERY`.
- Run `Explain`, `⌘⇧E` (`Ctrl+Shift+E`), or `Explain Analyze`, `⌘⇧⌥E` (`Ctrl+Shift+Alt+E`), in the [SQL editor](https://bobbytables.app/docs/sql-editor).

## Engine notes

TiDB does not support stored routines, triggers or scheduled events, so the catalog leaves them out. The snapshot dialog lists `Stored procedures and functions`, `Triggers` and `Events` under `Not included`. When another transaction changes the same data, the commit dialog keeps your pending changes and asks you to retry the complete transaction. When the schema changes during a commit, refresh the schema and review the pending changes before retrying.

## Good to know

- TiDB DDL is not transactional, so a failed structure change reports which earlier statements were already applied.
- `FULLTEXT` indexes depend on the TiDB Cloud deployment.
- Generated IDs can have gaps and need not follow commit order.

## Related

- [MySQL](https://bobbytables.app/docs/mysql.md)
- [Snapshots](https://bobbytables.app/docs/snapshots.md)
- [Editing](https://bobbytables.app/docs/editing.md)
- [Engines, file sources and platforms](https://bobbytables.app/docs/engines.md)
