Skip to content

Commit

Permalink
Bulk update integer display width
Browse files Browse the repository at this point in the history
Signed-off-by: Aolin <[email protected]>
  • Loading branch information
Oreoxmt committed Nov 19, 2024
1 parent 724e0e0 commit 915153f
Show file tree
Hide file tree
Showing 46 changed files with 253 additions and 253 deletions.
2 changes: 1 addition & 1 deletion auto-increment.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ SHOW CREATE TABLE t;
| Table | Create Table |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`a` int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=101 /*T![auto_id_cache] AUTO_ID_CACHE=100 */ |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion auto-random.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ tidb> SHOW CREATE TABLE t;
| Table | Create Table |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
`a` bigint NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,
`b` varchar(255) DEFAULT NULL,
PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T! PRE_SPLIT_REGIONS=2 */ |
Expand Down
2 changes: 1 addition & 1 deletion basic-sql-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ CREATE TABLE table_name column_name data_type constraint;

```sql
CREATE TABLE person (
id INT(11),
id int,
name VARCHAR(255),
birthday DATE
);
Expand Down
8 changes: 4 additions & 4 deletions cached-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SHOW CREATE TABLE users;
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| users | CREATE TABLE `users` (
`id` bigint(20) NOT NULL,
`id` bigint NOT NULL,
`name` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /* CACHED ON */ |
Expand Down Expand Up @@ -170,10 +170,10 @@ SHOW CREATE TABLE mysql.table_cache_meta\G
*************************** 1. row ***************************
Table: table_cache_meta
Create Table: CREATE TABLE `table_cache_meta` (
`tid` bigint(11) NOT NULL DEFAULT '0',
`tid` bigint NOT NULL DEFAULT '0',
`lock_type` enum('NONE','READ','INTEND','WRITE') NOT NULL DEFAULT 'NONE',
`lease` bigint(20) NOT NULL DEFAULT '0',
`oldReadLease` bigint(20) NOT NULL DEFAULT '0',
`lease` bigint NOT NULL DEFAULT '0',
`oldReadLease` bigint NOT NULL DEFAULT '0',
PRIMARY KEY (`tid`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
1 row in set (0.00 sec)
Expand Down
2 changes: 1 addition & 1 deletion clustered-indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mysql> SHOW CREATE TABLE t;
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` bigint(20) NOT NULL,
`a` bigint NOT NULL,
`b` varchar(255) DEFAULT NULL,
PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
Expand Down
6 changes: 3 additions & 3 deletions constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ SHOW CREATE TABLE t;
| Table | Create Table |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`a` int DEFAULT NULL,
`b` int DEFAULT NULL,
`c` int DEFAULT NULL,
CONSTRAINT `c1` CHECK ((`b` > `c`)),
CONSTRAINT `t_chk_1` CHECK ((`a` > 10)) /*!80016 NOT ENFORCED */,
CONSTRAINT `t_chk_2` CHECK ((1 < `c`))
Expand Down
6 changes: 3 additions & 3 deletions cost-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ mysql> SHOW CREATE TABLE t;
| Table | Create Table |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`a` int DEFAULT NULL,
`b` int DEFAULT NULL,
`c` int DEFAULT NULL,
KEY `b` (`b`),
KEY `c` (`c`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
Expand Down
50 changes: 25 additions & 25 deletions develop/dev-guide-bookshop-schema-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ WHERE table_schema LIKE 'bookshop';

| 字段名 | 类型 | 含义 |
|--------------|---------------|---------------------------------------|
| id | bigint(20) | 书籍的唯一标识 |
| id | bigint | 书籍的唯一标识 |
| title | varchar(100) | 书籍名称 |
| type | enum | 书籍类型(如:杂志、动漫、教辅等) |
| stock | bigint(20) | 库存 |
| stock | bigint | 库存 |
| price | decimal(15,2) | 价格 |
| published_at | datetime | 出版时间 |

Expand All @@ -148,19 +148,19 @@ WHERE table_schema LIKE 'bookshop';

| 字段名 | 类型 | 含义 |
|------------|--------------|-------------------------------------|
| id | bigint(20) | 作者的唯一标识 |
| id | bigint | 作者的唯一标识 |
| name | varchar(100) | 姓名 |
| gender | tinyint(1) | 生理性别 (0: 女, 1: 男,NULL: 未知) |
| birth_year | smallint(6) | 生年 |
| death_year | smallint(6) | 卒年 |
| gender | tinyint | 生理性别 (0: 女, 1: 男,NULL: 未知) |
| birth_year | smallint | 生年 |
| death_year | smallint | 卒年 |

### `users`

该表用于存储使用 Bookshop 应用程序的用户。

| 字段名 | 类型 | 含义 |
|----------|---------------|----------------|
| id | bigint(20) | 用户的唯一标识 |
| id | bigint | 用户的唯一标识 |
| balance | decimal(15,2) | 余额 |
| nickname | varchar(100) | 昵称 |

Expand All @@ -181,19 +181,19 @@ WHERE table_schema LIKE 'bookshop';

| 字段名 | 类型 | 含义 |
|-----------|------------|--------------------------------------------|
| book_id | bigint(20) | 书籍的唯一标识(关联至 [books](#books-表)|
| author_id | bigint(20) | 作者的唯一标识(关联至 [authors](#authors-表)|
| book_id | bigint | 书籍的唯一标识(关联至 [books](#books-表)|
| author_id | bigint | 作者的唯一标识(关联至 [authors](#authors-表)|

### `orders`

该表用于存储用户购买书籍的订单信息。

| 字段名 | 类型 | 含义 |
|------------|------------|--------------------------------------------|
| id | bigint(20) | 订单的唯一标识 |
| book_id | bigint(20) | 书籍的唯一标识(关联至 [books](#books-表)|
| user_id | bigint(20) | 用户唯一标识(关联至 [users](#users-表)|
| quantity | tinyint(4) | 购买数量 |
| id | bigint | 订单的唯一标识 |
| book_id | bigint | 书籍的唯一标识(关联至 [books](#books-表)|
| user_id | bigint | 用户唯一标识(关联至 [users](#users-表)|
| quantity | tinyint | 购买数量 |
| ordered_at | datetime | 购买时间 |

## 数据库初始化 `dbinit.sql` 脚本
Expand All @@ -205,29 +205,29 @@ CREATE DATABASE IF NOT EXISTS `bookshop`;

DROP TABLE IF EXISTS `bookshop`.`books`;
CREATE TABLE `bookshop`.`books` (
`id` bigint(20) AUTO_RANDOM NOT NULL,
`id` bigint AUTO_RANDOM NOT NULL,
`title` varchar(100) NOT NULL,
`type` enum('Magazine', 'Novel', 'Life', 'Arts', 'Comics', 'Education & Reference', 'Humanities & Social Sciences', 'Science & Technology', 'Kids', 'Sports') NOT NULL,
`published_at` datetime NOT NULL,
`stock` int(11) DEFAULT '0',
`stock` int DEFAULT '0',
`price` decimal(15,2) DEFAULT '0.0',
PRIMARY KEY (`id`) CLUSTERED
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

DROP TABLE IF EXISTS `bookshop`.`authors`;
CREATE TABLE `bookshop`.`authors` (
`id` bigint(20) AUTO_RANDOM NOT NULL,
`id` bigint AUTO_RANDOM NOT NULL,
`name` varchar(100) NOT NULL,
`gender` tinyint(1) DEFAULT NULL,
`birth_year` smallint(6) DEFAULT NULL,
`death_year` smallint(6) DEFAULT NULL,
`gender` tinyint DEFAULT NULL,
`birth_year` smallint DEFAULT NULL,
`death_year` smallint DEFAULT NULL,
PRIMARY KEY (`id`) CLUSTERED
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

DROP TABLE IF EXISTS `bookshop`.`book_authors`;
CREATE TABLE `bookshop`.`book_authors` (
`book_id` bigint(20) NOT NULL,
`author_id` bigint(20) NOT NULL,
`book_id` bigint NOT NULL,
`author_id` bigint NOT NULL,
PRIMARY KEY (`book_id`,`author_id`) CLUSTERED
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

Expand All @@ -252,10 +252,10 @@ CREATE TABLE `bookshop`.`users` (

DROP TABLE IF EXISTS `bookshop`.`orders`;
CREATE TABLE `bookshop`.`orders` (
`id` bigint(20) AUTO_RANDOM NOT NULL,
`book_id` bigint(20) NOT NULL,
`user_id` bigint(20) NOT NULL,
`quality` tinyint(4) NOT NULL,
`id` bigint AUTO_RANDOM NOT NULL,
`book_id` bigint NOT NULL,
`user_id` bigint NOT NULL,
`quality` tinyint NOT NULL,
`ordered_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) CLUSTERED,
KEY `orders_book_id_idx` (`book_id`)
Expand Down
8 changes: 4 additions & 4 deletions develop/dev-guide-create-secondary-indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ KEY `{index_name}` (`{column_names}`)

| 字段名 | 类型 | 含义 |
| :----------: | :-----------: | :-----------------------------------: |
| id | bigint(20) | 书籍的唯一标识 |
| id | bigint | 书籍的唯一标识 |
| title | varchar(100) | 书籍名称 |
| type | enum | 书籍类型(如:杂志、动漫、教辅等) |
| stock | bigint(20) | 库存 |
| stock | bigint | 库存 |
| price | decimal(15,2) | 价格 |
| published_at | datetime | 出版时间 |

```sql
CREATE TABLE `bookshop`.`books` (
`id` bigint(20) AUTO_RANDOM NOT NULL,
`id` bigint AUTO_RANDOM NOT NULL,
`title` varchar(100) NOT NULL,
`type` enum('Magazine', 'Novel', 'Life', 'Arts', 'Comics', 'Education & Reference', 'Humanities & Social Sciences', 'Science & Technology', 'Kids', 'Sports') NOT NULL,
`published_at` datetime NOT NULL,
`stock` int(11) DEFAULT '0',
`stock` int DEFAULT '0',
`price` decimal(15,2) DEFAULT '0.0',
PRIMARY KEY (`id`) CLUSTERED
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
Expand Down
4 changes: 2 additions & 2 deletions develop/dev-guide-index-best-practice.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ aliases: ['/zh/tidb/dev/index-best-practice']

```sql
CREATE TABLE `books` (
`id` bigint(20) AUTO_RANDOM NOT NULL,
`id` bigint AUTO_RANDOM NOT NULL,
`title` varchar(100) NOT NULL,
`type` enum('Magazine', 'Novel', 'Life', 'Arts', 'Comics', 'Education & Reference', 'Humanities & Social Sciences', 'Science & Technology', 'Kids', 'Sports') NOT NULL,
`published_at` datetime NOT NULL,
`stock` int(11) DEFAULT '0',
`stock` int DEFAULT '0',
`price` decimal(15,2) DEFAULT '0.0',
PRIMARY KEY (`id`) CLUSTERED
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
Expand Down
24 changes: 12 additions & 12 deletions develop/dev-guide-transaction-restraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public class EffectWriteSkew {

public static void createDoctorTable(Connection connection) throws SQLException {
connection.createStatement().executeUpdate("CREATE TABLE `doctors` (" +
" `id` int(11) NOT NULL," +
" `id` int NOT NULL," +
" `name` varchar(255) DEFAULT NULL," +
" `on_call` tinyint(1) DEFAULT NULL," +
" `shift_id` int(11) DEFAULT NULL," +
" `on_call` tinyint DEFAULT NULL," +
" `shift_id` int DEFAULT NULL," +
" PRIMARY KEY (`id`)," +
" KEY `idx_shift_id` (`shift_id`)" +
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin");
Expand Down Expand Up @@ -308,10 +308,10 @@ func prepareData(db *sql.DB) error {

func createDoctorTable(db *sql.DB) error {
_, err := db.Exec("CREATE TABLE IF NOT EXISTS `doctors` (" +
" `id` int(11) NOT NULL," +
" `id` int NOT NULL," +
" `name` varchar(255) DEFAULT NULL," +
" `on_call` tinyint(1) DEFAULT NULL," +
" `shift_id` int(11) DEFAULT NULL," +
" `on_call` tinyint DEFAULT NULL," +
" `shift_id` int DEFAULT NULL," +
" PRIMARY KEY (`id`)," +
" KEY `idx_shift_id` (`shift_id`)" +
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")
Expand Down Expand Up @@ -413,10 +413,10 @@ public class EffectWriteSkew {

public static void createDoctorTable(Connection connection) throws SQLException {
connection.createStatement().executeUpdate("CREATE TABLE `doctors` (" +
" `id` int(11) NOT NULL," +
" `id` int NOT NULL," +
" `name` varchar(255) DEFAULT NULL," +
" `on_call` tinyint(1) DEFAULT NULL," +
" `shift_id` int(11) DEFAULT NULL," +
" `on_call` tinyint DEFAULT NULL," +
" `shift_id` int DEFAULT NULL," +
" PRIMARY KEY (`id`)," +
" KEY `idx_shift_id` (`shift_id`)" +
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin");
Expand Down Expand Up @@ -637,10 +637,10 @@ func prepareData(db *sql.DB) error {

func createDoctorTable(db *sql.DB) error {
_, err := db.Exec("CREATE TABLE IF NOT EXISTS `doctors` (" +
" `id` int(11) NOT NULL," +
" `id` int NOT NULL," +
" `name` varchar(255) DEFAULT NULL," +
" `on_call` tinyint(1) DEFAULT NULL," +
" `shift_id` int(11) DEFAULT NULL," +
" `on_call` tinyint DEFAULT NULL," +
" `shift_id` int DEFAULT NULL," +
" PRIMARY KEY (`id`)," +
" KEY `idx_shift_id` (`shift_id`)" +
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")
Expand Down
4 changes: 2 additions & 2 deletions develop/dev-guide-unique-serial-number-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ uid-generator 生成的 64 位 ID 结构如下:
| 字段名 | 字段类型 | 字段说明 |
| -------- | ------------ | ---------------------------- |
| SEQ_NAME | varchar(128) | 序列名称,用来区分不同业务 |
| MAX_ID | bigint(20) | 当前序列已被分配出去的最大值 |
| STEP | int(11) | 步长,表示每次分配的号段长度 |
| MAX_ID | bigint | 当前序列已被分配出去的最大值 |
| STEP | int | 步长,表示每次分配的号段长度 |

应用程序每次按配置好的步长获取一段序列号,并同时更新数据库以持久化保存当前序列已被分配出去的最大值,然后在应用程序内存中即可完成序列号加工及分配动作。待一段号码耗尽之后,应用程序才会去获取新的号段,这样就有效降低了数据库写入压力。实际使用过程中,还可以适度调节步长以控制数据库记录的更新频度。

Expand Down
6 changes: 3 additions & 3 deletions dm/dm-manage-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ binlog-schema list -s mysql-replica-01 task_single db_single t1
"sources": [
{
"result": true,
"msg": "CREATE TABLE `t1` ( `c1` int(11) NOT NULL, `c2` int(11) DEFAULT NULL, PRIMARY KEY (`c1`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin",
"msg": "CREATE TABLE `t1` ( `c1` int NOT NULL, `c2` int DEFAULT NULL, PRIMARY KEY (`c1`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin",
"source": "mysql-replica-01",
"worker": "127.0.0.1:8262"
}
Expand Down Expand Up @@ -159,8 +159,8 @@ Global Flags:

```sql
CREATE TABLE `t1` (
`c1` int(11) NOT NULL,
`c2` bigint(11) DEFAULT NULL,
`c1` int NOT NULL,
`c2` bigint DEFAULT NULL,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
```
Expand Down
4 changes: 2 additions & 2 deletions dm/dm-open-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ curl -X 'GET' \
{
"schema_name": "db1",
"table_name": "table1",
"schema_create_sql": "CREATE TABLE `t1` (`id` int(11) NOT NULL AUTO_INCREMENT,PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"
"schema_create_sql": "CREATE TABLE `t1` (`id` int NOT NULL AUTO_INCREMENT,PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"
}
```

Expand All @@ -1637,7 +1637,7 @@ curl -X 'PUT' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"sql_content": "CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL, `c2` int(11) DEFAULT NULL, `c3` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;",
"sql_content": "CREATE TABLE `t1` ( `c1` int DEFAULT NULL, `c2` int DEFAULT NULL, `c3` int DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;",
"flush": true,
"sync": true
}'
Expand Down
4 changes: 2 additions & 2 deletions dm/dm-performance-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ aliases: ['/docs-cn/tidb-data-migration/dev/performance-test/']

```sql
CREATE TABLE `sbtest` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`k` int(11) NOT NULL DEFAULT '0',
`id` int NOT NULL AUTO_INCREMENT,
`k` int NOT NULL DEFAULT '0',
`c` char(120) CHARSET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
`pad` char(60) CHARSET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
Expand Down
Loading

0 comments on commit 915153f

Please sign in to comment.