MySQL converting to TINYINT
Under what circumstances will MySQL convert types to TINYINT? I know that a BOOL or BOOLEAN type in mysql DDL will automatically be converted to TINYINT(1) for for true or false. I am analyzing a database which has a type of varchar(16) on a field in one table, and tinyint(4) on the same field on another table? Eg t1.name varchar(15) and t2.name tinyint(4) where t1.name=t2.name.
Don't rely on implicit type conversion, do your datatype analysis manually:
First lets see what MySQL thinks as the best col-type for your data. Run a
SELECT * FROM table PROCEDURE Analyse()
Analyse your data further by saying
SELECT * FROM table WHERE varcharCol NOT REGEXP '^[0-9].*$'
To get all non-numeric values in varcharCol. If there are non you finally have to check value-ranges of different MySQL-types here.
Then you are ready to convert your varcharCol eg to TINYINT.
链接地址: http://www.djcxy.com/p/25146.html上一篇: 使用位数据类型将true / false存储到sql数据库是否实用?
下一篇: MySQL转换为TINYINT