Sign In Try Free

Developer Guide Overview

This guide is written for application developers, but if you are interested in the inner workings of TiDB or want to get involved in TiDB development, read theTiDB Kernel Development Guidefor more information about TiDB.

This tutorial shows how to quickly build an application using TiDB, the possible use cases of TiDB and how to handle common problems.

Before reading this page, it is recommended that you read theQuick Start Guide for the TiDB Database Platform.

This tutorial shows how to quickly build an application using TiDB Cloud, the possible use cases of TiDB Cloud and how to handle common problems.

TiDB basics

Before you start working with TiDB, you need to understand some important mechanisms of how TiDB works:

TiDB transaction mechanisms

TiDB supports distributed transactions and offers bothoptimistic transactionandpessimistic transactionmodes. The current version of TiDB uses thepessimistic transactionmode by default, which allows you to transact with TiDB as you would with a traditional monolithic database (for example, MySQL).

You can start a transaction usingBEGIN, explicitly specify apessimistic transactionusingBEGIN PESSIMISTIC, or explicitly specify anoptimistic transactionusingBEGIN OPTIMISTIC. After that, you can either commit (COMMIT) or roll back (ROLLBACK) the transaction.

TiDB guarantees atomicity for all statements between the start ofBEGINand the end ofCOMMITorROLLBACK, that is, all statements that are executed during this period either succeed or fail as a whole. This is used to ensure data consistency you need for application development.

If you are not sure what anoptimistic transactionis, doNOTuse it yet. Becauseoptimistic transactionsrequire that the application can correctly handleall errorsreturned by theCOMMITstatement. If you are not sure how your application handles them, use apessimistic transactioninstead.

If you are not sure what anoptimistic transactionis, doNOTuse it yet. Becauseoptimistic transactionsrequire that the application can correctly handleall errorsreturned by theCOMMITstatement. If you are not sure how your application handles them, use apessimistic transactioninstead.

The way applications interact with TiDB

TiDB is highly compatible with the MySQL protocol and supportsmost MySQL syntax and features, so most MySQL connection libraries are compatible with TiDB. If your application framework or language does not have an official adaptation from PingCAP, it is recommended that you use MySQL's client libraries. More and more third-party libraries are actively supporting TiDB's different features.

由于TiDB与MySQL协议兼容nd MySQL syntax, most of the ORMs that support MySQL are also compatible with TiDB.

Read more

Download PDF Request docs changes Ask questions on Discord
Playground
New
One-stop & interactive experience of TiDB's capabilities WITHOUT registration.
Was this page helpful?
Products
TiDB
TiDB Dedicated
TiDB Serverless
Pricing
Get Demo
Get Started
©2023PingCAP. All Rights Reserved.