Skip to content

Commit

Permalink
Bulk update integer display width (pingcap#19393)
Browse files Browse the repository at this point in the history
  • Loading branch information
dveeden authored Dec 2, 2024
1 parent ab637ac commit 22341b8
Show file tree
Hide file tree
Showing 46 changed files with 255 additions and 255 deletions.
2 changes: 1 addition & 1 deletion auto-increment.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,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 @@ -82,7 +82,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 @@ -100,7 +100,7 @@ For example, to create a table named `person` which includes fields such as numb

```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 @@ -106,7 +106,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 @@ -166,10 +166,10 @@ This table stores the basic information of books.

| Field name | Type | Description |
|--------------|---------------|------------------------------------------------------------------|
| id | bigint(20) | Unique ID of a book |
| id | bigint | Unique ID of a book |
| title | varchar(100) | Title of a book |
| type | enum | Type of a book (for example, magazine, animation, or teaching aids) |
| stock | bigint(20) | Stock |
| stock | bigint | Stock |
| price | decimal(15,2) | Price |
| published_at | datetime | Date of publish |

Expand All @@ -179,19 +179,19 @@ This table stores basic information of authors.

| Field name | Type | Description |
|------------|--------------|-------------------------------------------------------|
| id | bigint(20) | Unique ID of an author |
| id | bigint | Unique ID of an author |
| name | varchar(100) | Name of an author |
| gender | tinyint(1) | Biological gender (0: female, 1: male, NULL: unknown) |
| birth_year | smallint(6) | Year of birth |
| death_year | smallint(6) | Year of death |
| gender | tinyint | Biological gender (0: female, 1: male, NULL: unknown) |
| birth_year | smallint | Year of birth |
| death_year | smallint | Year of death |

### `users` table

This table stores information of Bookshop users.

| Field name | Type | Description |
|------------|---------------|-----------------------|
| id | bigint(20) | Unique ID of a user |
| id | bigint | Unique ID of a user |
| balance | decimal(15,2) | Balance |
| nickname | varchar(100) | Nickname |

Expand All @@ -212,19 +212,19 @@ An author may write multiple books, and a book may involve more than one author.

| Field name | Type | Description |
|------------|------------|--------------------------------------------------------------|
| book_id | bigint(20) | Unique ID of a book (linked to [books](#books-table)) |
| author_id | bigint(20) | Unique ID of an author(Link to [authors](#authors-table)|
| book_id | bigint | Unique ID of a book (linked to [books](#books-table)) |
| author_id | bigint | Unique ID of an author(Link to [authors](#authors-table)|

### `orders` table

This table stores user purchase information.

| Field name | Type | Description |
|------------|------------|----------------------------------------------------------------|
| id | bigint(20) | Unique ID of an order |
| book_id | bigint(20) | Unique ID of a book (linked to [books](#books-table)) |
| user_id | bigint(20) | User unique identifier (associated with [users](#users-table)) |
| quantity | tinyint(4) | Purchase quantity |
| id | bigint | Unique ID of an order |
| book_id | bigint | Unique ID of a book (linked to [books](#books-table)) |
| user_id | bigint | User unique identifier (associated with [users](#users-table)) |
| quantity | tinyint | Purchase quantity |
| ordered_at | datetime | Purchase time |

## Database initialization script `dbinit.sql`
Expand All @@ -236,29 +236,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 @@ -283,10 +283,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 @@ -73,22 +73,22 @@ The fields in the `books` table are as follows:

| Field name | Type | Field description |
|--------------|---------------|------------------------------------------------------------------|
| id | bigint(20) | Unique ID of the book |
| id | bigint | Unique ID of the book |
| title | varchar(100) | Book title |
| type | enum | Types of books (for example, magazines, animations, and teaching aids) |
| stock | bigint(20) | Stock |
| stock | bigint | Stock |
| price | decimal(15,2) | Price |
| published_at | datetime | Date of publishing |

The `books` table is created using the following SQL statement:

```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 @@ -15,11 +15,11 @@ This section takes the `books` table in the [bookshop](/develop/dev-guide-booksh

```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 @@ -83,10 +83,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 @@ -307,10 +307,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 @@ -410,10 +410,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 @@ -632,10 +632,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 @@ -43,8 +43,8 @@ The number allocation solution can be understood as bulk acquisition of auto-inc
| Field Name | Field Type | Field Description |
| -------- | ------------ | ---------------------------- |
| `SEQ_NAME` | varchar(128) | The name of the sequence, used to distinguish different applications. |
| `MAX_ID` | bigint(20) | The maximum value of the current sequence that has been allocated. |
| `STEP` | int(11) | The step, which indicates the length of each assigned segment. |
| `MAX_ID` | bigint | The maximum value of the current sequence that has been allocated. |
| `STEP` | int | The step, which indicates the length of each assigned segment. |

Every time, the application gets a segment of sequence numbers at the configured step. It updates the database at the same time to persist the maximum value of the current sequence that has been allocated. The processing and allocation of sequence numbers are completed in the application's memory. After a segment of sequence numbers is used up, the application gets a new segment of sequence numbers, which effectively alleviates the pressure on the database write. In practice, you can also adjust the step to control the frequency of database updates.

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 @@ -124,7 +124,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 @@ -163,8 +163,8 @@ If you want to set the table schema of the ``` `db_single`.`t1` ``` table corres

```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
Loading

0 comments on commit 22341b8

Please sign in to comment.