Is there a way i can create a column in a table which will only hold milliseconds value. I have a requirement where i have to store only LLLCCC(milliseconds) value in a column.
Asked
Active
Viewed 200 times
0
-
can't you use integer(6) for that?? – cosmos Jun 17 '13 at 16:18
1 Answers
0
If you need to store a valid interval which you can manipulate as an interval (aggregate, perform interval arithmetic against, etc.) you can use the data type INTERVAL SECOND(1,6)
in your table definition. If all values must be less than 1 second you can use a column level constraint to enforce the acceptable range of values.
CREATE VOLATILE TABLE MyTable, NO FALLBACK
(ColA SMALLINT NOT NULL,
MyInterval INTERVAL SECOND(1,6) NOT NULL)
PRIMARY INDEX (ColA) ON COMMIT PRESERVE ROWS;
INSERT INTO MyTable VALUES (1, INTERVAL '0.244569' SECOND);
SELECT *
FROM MyTable;
EDIT:
You can certainly store these values outside of their native format using CHAR(6), DECIMAL(6), or INTEGER. However, your ability to manipulate the values outside their native format becomes complicated.

Rob Paller
- 7,736
- 29
- 26
-
Thanks Rob, that did work :-) but can i only store 244569 in the column...with the time format?? @user2407394 : i am sorry i know we can store that as integer. But i don't know as of now for what this column is gonna be used for so trying to consider all scenarios and pros and cons for that – Anantha Jun 17 '13 at 18:29