Skip to content

Commit

Permalink
fix partition table doc error (#5903) (#5911)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Jul 1, 2021
1 parent fbda53a commit 7f14085
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions partitioned-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ CREATE TABLE employees (
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
job_code INT NOT NULL,
separated DATE DEFAULT '9999-12-31',
job_code INT,
store_id INT NOT NULL
);
```
Expand All @@ -43,8 +43,8 @@ CREATE TABLE employees (
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
job_code INT NOT NULL,
separated DATE DEFAULT '9999-12-31',
job_code INT,
store_id INT NOT NULL
)

Expand All @@ -58,7 +58,7 @@ PARTITION BY RANGE (store_id) (

In this partition scheme, all rows corresponding to employees whose `store_id` is 1 through 5 are stored in the `p0` partition while all employees whose `store_id` is 6 through 10 are stored in `p1`. Range partitioning requires the partitions to be ordered, from lowest to highest.

If you insert a row of data `(72, 'Tom', 'John', '2015-06-25', NULL, 15)`, it falls in the `p2` partition. But if you insert a record whose `store_id` is larger than 20, an error is reported because TiDB can not know which partition this record should be inserted into. In this case, you can use `MAXVALUE` when creating a table:
If you insert a row of data `(72, 'Tom', 'John', '2015-06-25', NULL, NULL, 15)`, it falls in the `p2` partition. But if you insert a record whose `store_id` is larger than 20, an error is reported because TiDB can not know which partition this record should be inserted into. In this case, you can use `MAXVALUE` when creating a table:

{{< copyable "sql" >}}

Expand All @@ -68,8 +68,8 @@ CREATE TABLE employees (
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
job_code INT NOT NULL,
separated DATE DEFAULT '9999-12-31',
job_code INT,
store_id INT NOT NULL
)

Expand All @@ -93,8 +93,8 @@ CREATE TABLE employees (
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
job_code INT NOT NULL,
separated DATE DEFAULT '9999-12-31',
job_code INT,
store_id INT NOT NULL
)

Expand All @@ -117,7 +117,7 @@ CREATE TABLE employees (
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
separated DATE DEFAULT '9999-12-31',
job_code INT,
store_id INT
)
Expand Down Expand Up @@ -293,7 +293,7 @@ CREATE TABLE employees_1 (
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
separated DATE DEFAULT '9999-12-31',
job_code INT,
store_id INT,
city VARCHAR(15)
Expand All @@ -318,7 +318,7 @@ CREATE TABLE employees_2 (
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
separated DATE DEFAULT '9999-12-31',
job_code INT,
store_id INT,
city VARCHAR(15)
Expand Down Expand Up @@ -367,7 +367,7 @@ CREATE TABLE employees (
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
separated DATE DEFAULT '9999-12-31',
job_code INT,
store_id INT
)
Expand All @@ -388,7 +388,7 @@ CREATE TABLE employees (
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE NOT NULL DEFAULT '9999-12-31',
separated DATE DEFAULT '9999-12-31',
job_code INT,
store_id INT
)
Expand Down

0 comments on commit 7f14085

Please sign in to comment.