What type should I use to store values like "999999.99" in Cassandra?
0
votes
2
answers
175
views
I wanna add a price column to my table to be able to store values from
0.0
to 999999.99
. I tried price DECIMAL(8,2)
but it seems it doesn't work. How can I store such a value?
I am also wondering to know if there would be any pre-post processing needed after that because I use NodeJS/TypeScript in backend that handles all numeric values using
number` type!
I also like to know if is it a better idea to use string type insted?
EDIT
: For example if I try
CREATE TABLE IF NOT EXISTS products.test(
id TEXT PRIMARY KEY,
price DECIMAL(8,2));
I get:
> SyntaxException: line 3:15 no viable alternative at input '(' (...
> TEXT PRIMARY KEY, price [DECIMAL](...)
But the following works with no problems:
CREATE TABLE IF NOT EXISTS products.test(
id TEXT PRIMARY KEY,
price INT);
Asked by user3486308
(151 rep)
Jun 9, 2023, 10:13 PM
Last activity: Jun 22, 2023, 07:07 AM
Last activity: Jun 22, 2023, 07:07 AM