MySQL Forums
Forum List  »  General

Re: Why is STR_TO_DATE failing?
Posted by: Peter Brawley
Date: July 22, 2022 09:51AM

Skew: if you store dt, d and t columns representing a datetime, an edit can create divergence amongst the values.

Generated columns: https://dev.mysql.com/doc/refman/8.0/en/create-table-generated-columns.html

For example ...

drop table if exists t;
create table t(
  dt datetime,
  d date generated always as ( date(dt) ) virtual, 
  t time generated always as ( time(dt) ) virtual
);

dt is stored, d and t are auto-computed ("virtual"), always available, take up no space.



Edited 2 time(s). Last edit at 07/22/2022 10:28AM by Peter Brawley.

Options: ReplyQuote


Subject
Written By
Posted
Re: Why is STR_TO_DATE failing?
July 22, 2022 09:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.