Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix partition table doc error (#5903) #5911

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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