I am converting a SQL Server table structure to a MySQL table structure, and I need to know how to properly declare the column data types within the
CREATE TABLE statement.
I have a CSV file where each row gives me column info like so:
columnName,sqlServDataType,maxLength,precision,scale,isNullable,isPrimaryKey idYear,int,4,10,0,0,1 ...
I have a file / information on how I will programmatically map the SQL Server data type to the MySQL data type, but I need to know what MySQL data types require the max length declaration in a CREATE TABLE statement.
So for instance, in MySQL you can declare
columnName INT or
columnName INT(4) though there's really no point, from what I've read. However, doing something like
VARCHAR(40) is important for both performance and data insertion concerns. Make a column too big for small data, it's inefficient. Make a column's max length too small for a given chunk of data, and the insertion will fail.
Ultimately for a given MySQL data type, I need to know if the max length e.g.
VARCHAR(40) is required or not. I couldn't find much in the documentation.