1

I am learning about MariaDBs column types and noticed this on my MariaDB db (latest dockerized 10.3.13), connected via HeidiSQL 10.

I can't set the default value for my FLOAT column to a value that contains decimal places:

enter image description here

After hitting save the default value is just 42. This also happens when performing the ALTER / CREATE TABLE query manually. (In the screenshot the column type is FLOAT but I also tested with FLOAT(10,2).)

Edit: When creating the table with this SQL statement, new rows will have the default value 42 instead of 42.11:

CREATE TABLE test2 (
    `float` FLOAT(10,2) NOT NULL DEFAULT '42.11'
)

Why?

FabianTe
  • 516
  • 4
  • 22
  • Perhaps you can try: ALTER TABLE `table` ADD COLUMN `column` FLOAT(10,2) NOT NULL DEFAULT '42.11' – Jinesh Shah Apr 01 '19 at 13:56
  • locale issue? Decimal comma? – jarlh Apr 01 '19 at 14:00
  • I don't think it is a locale issue. Using '.' as the decimal place is working if I insert rows and using ',' will throw an error. – FabianTe Apr 01 '19 at 14:20
  • @FabianTe Set the decimal length to something like 10,2 as it may otherwise default to 0. – Jim Castro Apr 01 '19 at 14:39
  • @JimCastro Good idea. I just tested this with FLOAT(10,2) but the default value is still only 42. – FabianTe Apr 01 '19 at 14:42
  • @FabianTe I'm running HeidiSQL on Linux Mint using WINE and it works for me so we get back to is it a locale issue? Should you enter the length as 10.2 and the default value as 42,11 ? – Jim Castro Apr 01 '19 at 16:17

1 Answers1

1

I've just reported that to HeidiSQL, This is only a display bug on HeidiSQL: https://github.com/HeidiSQL/HeidiSQL/issues/593

You can execute "SHOW CREATE TABLE test2" or insert data into test2, this will show you that default value is not truncated.

Diego Dupin
  • 1,106
  • 8
  • 9