MariaDB Datatype length keeps changing

Conz's profile image Conz posted 4 years ago in General Permalink

I haven't had to use HeidiSQL to mess with tables for a while and just updated it to the latest version as I had to figure out a new database. I noticed that quite often the length value at least for smallint's is constantly changing between having a value of 6 or 5. I make a new table and it gets a length of 5, I add a new field to an existing table and it has a length of 6

I started noticing because foreign keys complain when the lengths don't match but I was sure I had set both to the same datatype.

ansgar's profile image ansgar posted 4 years ago Permalink

That sounds as if you have some SMALLINT's signed and some unsigned, which makes the difference of one character. For a foreign the length is irrelevant, it's the unsigned flag which is important.

Conz's profile image Conz posted 4 years ago Permalink

Looks like it, I haven't often used smallint's and it was only happening with those.

Please login to leave a reply, or register at first.