English 中文(简体)
MySQL 日期时间转换的 MySQL 时间戳
原标题:MySQL timestamp to datetime conversion
  • 时间:2012-05-24 22:19:00
  •  标签:
  • mysql
  • date

我有一个非常大的 MySQL 表格( 百万列), 获得新数据的时间非常短 20 分钟 。 我一开始犯了一个错误, 并且有一个时间戳数据, 而我真正想要的是一个日期时间列。 我怎样才能将当前表格插入或迁移到一个新的表格, 越快越好, WHILE 仍然能够将新数据附加到旧表格或新表格?

最佳回答

这取决于什么/谁在使用数据库, 以及你有什么控制...

一种办法可以是:

  • create a new table (with desired data structure) (CREATE TABLE...)
  • amend code/processes that are writing to the database, so that they write to both the old and the new tables (but continue to read from the old table)
  • when everything is writing to both, copy the old data from the old table to new table (INSERT ... SELECT ...)
  • amend code/processes that are reading from the database so that they read from the new table (but continue to write to both)
  • when everything is reading from the new table, amend the code/processes to only write to the new table
  • when everything is reading from and writing to the new table (alone), you can delete the old table. (DROP TABLE...)

您也可以通过改变现有表格(即创建新列)来做类似的事情,但如果您的数据每20分钟更新一次,您可能会有一个非常大的表格,在这种情况下,ALTER Table查询需要一段时间才能运行,所以我建议您迁移到一个新的表格。

问题回答

暂无回答




相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签