Skip to content

Commit

Permalink
fix partition table doc error (pingcap#5903)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joyinqin authored Jul 1, 2021
1 parent 79f4f71 commit 3aebca1
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 @@ -28,8 +28,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 @@ -44,8 +44,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 @@ -59,7 +59,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 @@ -69,8 +69,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 @@ -94,8 +94,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 @@ -118,7 +118,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 @@ -294,7 +294,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 @@ -319,7 +319,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 @@ -368,7 +368,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 @@ -389,7 +389,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 3aebca1

Please sign in to comment.