# Primary Key - Clustered Index
```
tidb> CREATE TABLE test.example_table1 (
  ~!@example_pk BIGINT AUTO_RANDOM PRIMARY KEY@!~,
  example_content VARCHAR(60)
);

tidb> CREATE TABLE test.example_table2 (
  ~!@example_pk CHAR(10) PRIMARY KEY CLUSTERED@!~,
  example_content VARCHAR(60)
);

tidb> CREATE TABLE test.example_table3(
  example_pk1 INT,
  example_pk2 VARCHAR(10),
  example_content VARCHAR(60),
  ~!@PRIMARY KEY (example_pk1, example_pk2) CLUSTERED@!~ 
);

tidb> SELECT TABLE_NAME, TIDB_PK_TYPE
  FROM information_schema.tables 
  WHERE table_schema = 'test' 
  AND table_name in ('example_table1','example_table2','example_table3');

+----------------+--------------+
| TABLE_NAME     | TIDB_PK_TYPE |
+----------------+--------------+
| example_table2 | ~!@CLUSTERED@!~    |
| example_table1 | ~!@CLUSTERED@!~    |
| example_table3 | ~!@CLUSTERED@!~    |
+----------------+--------------+
```
![`smart`](../diagram/ClusteredTableWithPrimaryKey_en_001_20231116.png)
------------------------------------------------------------------------------
In a relational database, a primary key is a unique identifier for each record in a table. It ensures that each row in a table is uniquely identified, and it cannot have a NULL value. A primary key is often supported by a unique index in traditional RDBMS, which aids in quicker data retrieval.

A clustered index determines the physical order of data rows in a table based on the indexed columns. When a table has a clustered index, the rows are stored on disk in the same order as the index. This organization can improve query performance, as related data is stored together on disk.

In a TiDB clustered index scenario, the rows of the table are organized on disk according to the order of the primary key. This means that the data itself is physically ordered on disk based on the primary key values. The primary key of the table is the same as the key of the mapped key-value pair in the TiKV map. There is a one-to-one correspondence between the rows in the TiDB table and the key-value pair entries in TiKV store.

The TiKV KV entry comprises the following key and value:
- The key is the primary key with the table ID prefix.
- The value comes from the other columns except the primary key.


