Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.mysql > #5399

Re: Storing dates

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.databases, comp.databases.mysql, comp.lang.php
Subject Re: Storing dates
Followup-To comp.databases
Date 2014-06-22 14:38 +0200
Organization PointedEars Software (PES)
Message-ID <2353292.cnrgqz3L4O@PointedEars.de> (permalink)
References (8 earlier) <hzk4wa449wa$.3xtj0jkxz78o$.dlg@40tude.net> <XnsA353998B95688dougmilmaccom@78.46.70.116> <210620142206250710%timstreater@greenbee.net> <lo4sa4$h1p$1@dont-email.me> <210620142233257893%timstreater@greenbee.net>

Cross-posted to 3 groups.

Followups directed to: comp.databases

Show all headers | View raw


[F'up2 comp.databases]

Tim Streater wrote in comp.databases.mysql and comp.lang.php:

> Jerry Stuckle wrote:
>> On 6/21/2014 5:06 PM, Tim Streater wrote:
>> > I have a field which contains values like 3.7, 4.2, etc. But when I
>> > defined the field (in SQLite) I made it a TEXT field, forgetting that I
>> > would need to be able to sort on that field.
>> > 
>> > My workaround is to convert the string to floating at the time of the
>> > sort. In SQLite I do:
>> > 
>> >  ... ORDER BY ROUND(myfield,1);
>> > 
>> > which works just fine. Richard should look for something similar in
>> > mysql.
>> 
>> Why don't you fix your database?
>> 
>> The way you're doing it cannot use an index and will call round() for
>> EVERY row in the sort.
> 
> I'd have to ask a number of users to convert their data when they next
> upgrade the software. Trouble is in SQLite you can't just redefine a
> table column to be a different type; ALTER TABLE is somewhat limited.
> I'd have to copy the whole table to another, DROP the first one, RENAME
> the new one, VACUUM the database to get its size down.

True, but see also “Making Other Kinds Of Table Schema Changes” in 
<http://www.sqlite.org/lang_altertable.html>.

> OK, it's doable,
> but I'm replying on less-than-technically-savvy users to run a Terminal
> script on their own machine to effect this change.

If this is for an Android app (where SQLite is prevalent), you can use 
built-in versioning support to migrate the SQLite database table structure 
automagically with the next upgrade or downgrade.  BTDT.

<http://developer.android.com/guide/topics/data/data-storage.html#db>
<http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html>

Otherwise you can have a table with corresponding version information.  If 
it is missing or the corresponding record is missing, you can assume the old 
format and migrate the data accordingly.  Several SQL-based applications do 
this. 

For example, Magento (which by default is MySQL-InnoDB-based) holds the 
version of an extension in the table `core_resource`, and you can write 
migration scripts (named e.g. upgrade-$old_ver-$new_ver.php) that are 
automatically run if the current version differs but matches $old_ver, and 
the new extension version matches $new_ver, after which the version in 
`core_resource` is updated automatically to $new_ver.


PointedEars 
-- 
Sometimes, what you learn is wrong. If those wrong ideas are close to the 
root of the knowledge tree you build on a particular subject, pruning the 
bad branches can sometimes cause the whole tree to collapse.
  -- Mike Duffy in cljs, <news:Xns9FB6521286DB8invalidcom@94.75.214.39>

Back to comp.databases.mysql | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Putting it all together richard <noreply@example.com> - 2014-06-20 10:20 -0400
  Re: Putting it all together Evan Platt <evan@theobvious.espphotography.com.invalid> - 2014-06-20 08:11 -0700
    Re: Putting it all together richard <noreply@example.com> - 2014-06-20 11:24 -0400
      Re: Putting it all together Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-20 17:15 +0000
      Re: Putting it all together Evan Platt <evan@theobvious.espphotography.com.invalid> - 2014-06-20 20:01 -0700
  Re: Putting it all together Jürgen Exner <jurgenex@hotmail.com> - 2014-06-20 08:21 -0700
  Re: Putting it all together Norman Peelman <npeelman@cfl.rr.com> - 2014-06-20 21:06 -0400
  Re: Putting it all together Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-21 03:02 +0000
  Re: Putting it all together Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-21 03:09 +0000
  Re: Putting it all together Jürgen Exner <jurgenex@hotmail.com> - 2014-06-20 20:13 -0700
    Re: Putting it all together richard <noreply@example.com> - 2014-06-20 23:34 -0400
      Re: Putting it all together Jürgen Exner <jurgenex@hotmail.com> - 2014-06-20 20:48 -0700
      Re: Putting it all together Evan Platt <evan@theobvious.espphotography.com.invalid> - 2014-06-20 21:00 -0700
      Re: Putting it all together Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-21 04:22 +0000
        Re: Putting it all together Jürgen Exner <jurgenex@hotmail.com> - 2014-06-20 22:11 -0700
          Re: Putting it all together Evan Platt <evan@theobvious.espphotography.com.invalid> - 2014-06-20 22:39 -0700
        Re: Putting it all together gordonb.zp2md@burditt.org (Gordon Burditt) - 2014-06-21 04:15 -0500
          Storing dates (was: Putting it all together) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-21 12:15 +0200
            Re: Storing dates Luuk <luuk@invalid.lan> - 2014-06-21 13:09 +0200
            Re: Storing dates richard <noreply@example.com> - 2014-06-21 11:10 -0400
              Re: Storing dates Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-21 17:42 +0000
                Re: Storing dates richard <noreply@example.com> - 2014-06-21 14:28 -0400
                Re: Storing dates Jürgen Exner <jurgenex@hotmail.com> - 2014-06-21 12:04 -0700
                Re: Storing dates Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-21 19:06 +0000
                Re: Storing dates Tim Streater <timstreater@greenbee.net> - 2014-06-21 22:06 +0100
                Re: Storing dates Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-21 17:09 -0400
                Re: Storing dates Tim Streater <timstreater@greenbee.net> - 2014-06-21 22:33 +0100
                Re: Storing dates Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-21 17:49 -0400
                Re: Storing dates Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-22 14:38 +0200
                Re: Storing dates Jürgen Exner <jurgenex@hotmail.com> - 2014-06-21 14:31 -0700
                Re: Storing dates Tim Streater <timstreater@greenbee.net> - 2014-06-21 22:44 +0100
                Re: Storing dates Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-22 14:59 +0200
                Re: Storing dates "Erick T. Barkhuis" <erick.use-net@ardane.c.o.m> - 2014-06-23 05:54 +0000
                Re: Storing dates Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-21 23:19 +0000
                Re: Storing dates Arno Welzel <usenet@arnowelzel.de> - 2014-06-22 08:53 +0200
                Re: Storing dates "Erick T. Barkhuis" <erick.use-net@ardane.c.o.m> - 2014-06-22 08:03 +0000
                Re: Storing dates Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-22 09:29 -0400
                Re: Storing dates "Erick T. Barkhuis" <erick.use-net@ardane.c.o.m> - 2014-06-22 14:24 +0000
                Re: Storing dates Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-22 10:32 -0400
                Re: Storing dates "Erick T. Barkhuis" <erick.use-net@ardane.c.o.m> - 2014-06-22 14:45 +0000
                Re: Storing dates Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-22 19:44 +0000
                Re: Storing dates Jürgen Exner <jurgenex@hotmail.com> - 2014-06-22 08:26 -0700
                Re: Storing dates gordonb.q26od@burditt.org (Gordon Burditt) - 2014-06-22 10:00 -0500
                Re: Storing dates Arno Welzel <usenet@arnowelzel.de> - 2014-06-22 16:47 +0200
                Re: Storing dates richard <noreply@example.com> - 2014-06-22 13:55 -0400
                Re: Storing dates Jürgen Exner <jurgenex@hotmail.com> - 2014-06-22 12:31 -0700
                Re: Storing dates Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-24 22:27 +0200
                Re: Storing dates Jürgen Exner <jurgenex@hotmail.com> - 2014-06-24 13:41 -0700
                Re: Storing dates Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-24 20:29 -0400
                Re: Storing dates Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-25 08:17 +0200
                Re: Storing dates "Erick T. Barkhuis" <erick.use-net@ardane.c.o.m> - 2014-06-25 06:31 +0000
                Re: Storing dates Jürgen Exner <jurgenex@hotmail.com> - 2014-06-25 01:25 -0700
                Re: Storing dates Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-25 12:02 +0000
                Re: Storing dates "Erick T. Barkhuis" <erick.use-net@ardane.c.o.m> - 2014-06-25 12:17 +0000
                Re: Storing dates Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-22 19:52 +0000
                Re: Storing dates Arno Welzel <usenet@arnowelzel.de> - 2014-06-22 21:52 +0200
                Re: Storing dates richard <noreply@example.com> - 2014-06-22 14:05 -0400
                Re: Storing dates Arno Welzel <usenet@arnowelzel.de> - 2014-06-22 21:56 +0200
                Re: Storing dates richard <noreply@example.com> - 2014-06-22 22:46 -0400
                Re: Storing dates Arno Welzel <usenet@arnowelzel.de> - 2014-06-23 08:11 +0200
                Re: Storing dates richard <noreply@example.com> - 2014-06-23 02:37 -0400
                Re: Storing dates Arno Welzel <usenet@arnowelzel.de> - 2014-06-23 11:10 +0200
                Re: Storing dates Evan Platt <evan@theobvious.espphotography.com.invalid> - 2014-06-23 06:50 -0700
                Re: Storing dates richard <noreply@example.com> - 2014-06-23 11:13 -0400
                Re: Storing dates Evan Platt <evan@theobvious.espphotography.com.invalid> - 2014-06-23 09:13 -0700
                Re: Storing dates Arno Welzel <usenet@arnowelzel.de> - 2014-06-23 22:33 +0200
                Re: Storing dates richard <noreply@example.com> - 2014-06-22 23:04 -0400
                Re: Storing dates Arno Welzel <usenet@arnowelzel.de> - 2014-06-23 08:12 +0200
                Re: Storing dates Geoff Muldoon <geoff.muldoon@trap.gmail.com> - 2014-06-23 16:45 +1000
                Re: Storing dates richard <noreply@example.com> - 2014-06-23 07:58 -0400
                Re: Storing dates Jürgen Exner <jurgenex@hotmail.com> - 2014-06-23 09:50 -0700
                Re: Storing dates Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-23 19:02 +0200
                Re: Storing dates Geoff Muldoon <geoff.muldoon@trap.gmail.com> - 2014-06-24 12:00 +1000
                Re: Storing dates Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-24 22:38 +0200
                Re: Storing dates Geoff Muldoon <geoff.muldoon@trap.gmail.com> - 2014-06-25 09:03 +1000
                Re: Storing dates Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-24 20:27 -0400
                Re: Storing dates Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-25 17:15 +0200
                Re: Storing dates Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-25 11:43 -0400
                Re: Storing dates Geoff Muldoon <geoff.muldoon@trap.gmail.com> - 2014-06-25 11:34 +1000
                Re: Storing dates Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-25 08:20 +0200
                Re: Storing dates Jürgen Exner <jurgenex@hotmail.com> - 2014-06-22 15:30 -0700
                Re: Storing dates "Peter H. Coffin" <hellsop@ninehells.com> - 2014-06-22 20:10 -0500
          Re: Putting it all together Jürgen Exner <jurgenex@hotmail.com> - 2014-06-21 03:34 -0700
            Re: Putting it all together "Erick T. Barkhuis" <erick.use-net@ardane.c.o.m> - 2014-06-21 12:27 +0000
              Re: Putting it all together Jürgen Exner <jurgenex@hotmail.com> - 2014-06-21 08:25 -0700
      Re: Putting it all together Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-21 10:23 +0000
      Re: Putting it all together bill <william@TechServSys.com> - 2014-06-21 07:03 -0400
        Re: Putting it all together Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-21 15:11 +0000
      Re: Putting it all together "Peter H. Coffin" <hellsop@ninehells.com> - 2014-06-21 10:57 -0500
      Re: Putting it all together Arno Welzel <usenet@arnowelzel.de> - 2014-06-22 08:45 +0200

csiph-web