or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
MariaDB Temporal Table
Description
This is a HOWTO for database record/value version control, not for schema.
With MariaDB, now we can Versioning database records (values)
WITH SYSTEM VERSIONING
.Once we have tables configured correctly, Data Versions will be generated automatically everytime we have new data inserted or values updated.
Also note that when new values are as the same as the old ones, no modifications will be done and no new versions will be created; it just works like a automatic data dedup (de-duplication) feature which avoids adding repeating data.
Prerequirements:
docker run --name mariadb -e MYSQL_ROOT_PASSWORD=password -d mariadb
Prepare
Connect
Connect with client shipped with docker image Docker Hub
docker exec -it mariadb mysql -u root -p
Initialize
Create test database:
Table definition (Default)
Create a Temporal table with versioning support for all columns:
Exclusive table definition (Optional)
Inclusive table definition (Optional)
Partitioning - Storing the History Separately (Recommend)
Play with Data
Insert record
INSERT
always creates new version, as it creates a new data of values as a new record.Above command created the first row of records, and it's timestamps.
Update record
UPDATE
doesn't always generates new version:UPDATE
won't modify any value, so no new version.UPDATE
with different valuesNew version shows up.
UPDATE
with the same values as existing onesNo new version created.
UPDATE
with different values, againUPSERT -
UPDATE
when exist,INSERT
if not.Reference
Select data, in different ways
Select only current (latest) data
Select all versions of data
Select all versions of data and their duration (time)
Select data at a specific moment
Important notes
In some situations it might not work as expected
References