Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How does temporal tables work in Mysql?


What I have tried:

In microsoft sql server (t-sql), temporal table query is:

CREATE TABLE Department

(

  DeptID INT NOT NULL PRIMARY KEY CLUSTERED

 , DeptName VARCHAR(50) NOT NULL

 , ValidFrom DATETIME2 GENERATED ALWAYS AS ROW START NOT NULL

 , ValidTo DATETIME2 GENERATED ALWAYS AS ROW END NOT NULL

 , PERIOD FOR SYSTEM_TIME (ValidFrom, ValidTo)

)

WITH (SYSTEM_VERSIONING = ON);

What is the equivalent in mysql temporal table query as i am new to my sql?
Posted
Updated 15-Sep-22 1:07am

1 solution

MySQL doesn't have such a concept built-in.

If you can switch to MariaDB, version 10.3.x and later has system-versioned tables:
System-Versioned Tables - MariaDB Knowledge Base[^]

Otherwise, you'll have to implement it yourself. There's a discussion on DBA StackExchange which provides more details:
Implementing versioning system with MySQL[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900