~drizzle-trunk/drizzle/development

1994.4.28 by Marisa Plumb
fixes to date/time type, and added info from earlier discussions on time ranges
1
Date and Time Data Types
1994.4.23 by Marisa Plumb
new data types content
2
========================
3
1994.4.29 by Marisa Plumb
adding detail to date/time types doc
4
Of the SQL date and time types, Drizzle supports:
1994.4.23 by Marisa Plumb
new data types content
5
6
**Date/Time Types**
7
2165.2.1 by Andrew Hutchings
Initial cleanups
8
+------------+------------------------------+------------------------------+------------------------+---------------+---------------+
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
9
|Data Type   |Lowest Value (or NULL)        |Maximum Value                 |Description             |Storage Size   |Resolution     |
2165.2.1 by Andrew Hutchings
Initial cleanups
10
+============+==============================+==============================+========================+===============+===============+
11
|TIMESTAMP   |'0001-01-01 00:00:00'         |'9999-12-31 23:59:59'         |both date and time      |4 bytes        |1 second       |
12
+------------+------------------------------+------------------------------+------------------------+---------------+---------------+
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
13
|TIMESTAMP(6)|'0001-01-01 00:00:00.000000'  |'9999-12-31 23:59:59.999999'  |both date and time      |8 bytes        |1 microsecond  |
2165.2.1 by Andrew Hutchings
Initial cleanups
14
+------------+------------------------------+------------------------------+------------------------+---------------+---------------+
15
|DATE        |'0001-01-01'                  |'9999-12-31'                  |dates only              |4 bytes        |1 day          |
16
+------------+------------------------------+------------------------------+------------------------+---------------+---------------+
2165.2.6 by Andrew Hutchings
Missed something on temporal docs, now fixed
17
|TIME        |'00:00:00'                    |'23:59:59'                    |time of day             |4 bytes        |1 second       |
2165.2.1 by Andrew Hutchings
Initial cleanups
18
+------------+------------------------------+------------------------------+------------------------+---------------+---------------+
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
19
|DATETIME    |'0001-01-01 00:00:00'         |'9999-12-31 23:59:59'         |both date and time      |4 bytes        |1 second       |
2165.2.1 by Andrew Hutchings
Initial cleanups
20
+------------+------------------------------+------------------------------+------------------------+---------------+---------------+
1994.4.48 by Marisa Plumb
new date/time additions
21
22
TIMESTAMP and TIMESTAMP(6)
23
--------------------------
24
25
The regular TIMESTAMP data type does not store fractional seconds, and uses 4 bytes of storage.
26
1994.4.49 by Marisa Plumb
edit
27
To create a TIMESTAMP column that uses microseconds you simply need to specify TIMESTAMP(6) in your table definition. The (6) stands for microsecond granularity (since a microsecond is one millionth of a second). This means that fractional seconds are stored and returned with the field, and it uses 4 more bytes of storage than TIMESTAMP.
1994.4.48 by Marisa Plumb
new date/time additions
28
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
29
For example:
30
31
.. code-block:: mysql
1994.4.29 by Marisa Plumb
adding detail to date/time types doc
32
33
	CREATE TABLE `t1` (
34
	`a` INT DEFAULT NULL,
1994.4.48 by Marisa Plumb
new date/time additions
35
	`b` TIMESTAMP(6) NULL DEFAULT NULL
1994.4.29 by Marisa Plumb
adding detail to date/time types doc
36
	) ENGINE=InnoDB
37
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
38
You can then use the following (but note that ON DEFAULT/UPDATE CURRENT_TIMESTAMP works with microseconds as well):
39
40
.. code-block:: mysql
1994.4.29 by Marisa Plumb
adding detail to date/time types doc
41
42
	insert into t1 values (1, '2010-01-10 07:32:43.234567');
43
44
The new table now looks like this:
45
46
+------+----------------------------+
47
|a     |b                           |
2165.2.6 by Andrew Hutchings
Missed something on temporal docs, now fixed
48
+======+============================+
1994.4.29 by Marisa Plumb
adding detail to date/time types doc
49
|1     |2010-01-10 07:32:43.234567  |
50
+------+----------------------------+
51
1994.4.30 by Marisa Plumb
addition of date input
52
DATE
53
----
54
1994.5.30 by Stewart Smith
add explanation as to why 0000-00-00 is an invalid date. add fixmes about some of the TIME type restrictions
55
In Drizzle, valid date inputs begin at 0001-01-01 rather than 0000-00-00, which is not a valid date (there was no year 1, there is no month zero and there is no day zero).
1994.4.30 by Marisa Plumb
addition of date input
56
1994.4.29 by Marisa Plumb
adding detail to date/time types doc
57
TIME
58
----
59
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
60
Drizzle's TIME data type has a range of 00:00:00 - 23:59:59, while MySQL's TIME data type has a range of -838:59:59 - 838:59:59.
1994.4.39 by Marisa Plumb
new material to address https://bugs.launchpad.net/drizzle/+bug/684803, new functions
61
1994.4.49 by Marisa Plumb
edit
62
This brings Drizzle closer to the SQL standard. Negative time is not meant to be supported.
1994.5.30 by Stewart Smith
add explanation as to why 0000-00-00 is an invalid date. add fixmes about some of the TIME type restrictions
63
1994.4.49 by Marisa Plumb
edit
64
To prevent data loss to this type when converting from MySQL -> Drizzle, the conversion process changes TIME to an INT of the number of seconds. For example, 00:00:00 becomes 0, 01:00:00 becomes 3600, and -01:00:00 becomes -3600.
1994.4.39 by Marisa Plumb
new material to address https://bugs.launchpad.net/drizzle/+bug/684803, new functions
65
2194.5.4 by Andrew Hutchings
A few more minor fixups
66
More information on this can be found in the :ref:`drizzledump-migration-label`
67
section of this documentation.
1994.4.48 by Marisa Plumb
new date/time additions
68
69
DATETIME
70
--------
71
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
72
DATETIME defines a date that is combined with a time of day, based on 24-hour time. Unlike TIMESTAMP in that it does not support microseconds.
1994.4.48 by Marisa Plumb
new date/time additions
73
74