Take the following create table statement:
create table fruit
{
count int,
name varchar(32),
size float
}
Instead of those specific data types, why not have “string”, “number”, “boolean” or better yet, not having to specify any data types at all.
What are the technical reasons for having such specific data types? (as opposed to generic or no data type)
Imagine 20 millions rows in a table, with an int column where all the numbers are 1 through 10.
If you used a tinyint for that, it would take 1 byte. If you used a regular int, it would take 4 bytes. That’s four times the amount of disk space, 60 MBs more disk space.
Theoretically, you could design a database engine to “smart config” a table, but imagine our theoretical table where all of a sudden the database decides it need to allocate more bytes for the data in the column. The whole table would need to be re-paged, and the performance would slow to a crawl for potentially hours while the engine restructured the table.
There are so many edge cases and ways to get it wrong, that it would be more work to stay on top of automatic configuration than to just design your application properly in the first place.