When designing database tables, you must pay attention:
In Mysql, tinyint is signed by default, and the value range is -128 to 127. The unsigned attribute is to unsigned the number type. Unsigned tinyint is 0-255;
SQL Server supports bignt, Int, smallint, tinyint, the first three are signed, while tinyint is unsigned, and the value range is 0-255;
therefore, if the table structure is directly migrated in these two databases, Pay attention.
----------------------------
Use of zerofill:
CREATE TABLE `test` (
`u_id` INT(11) NOT NULL AUTO_INCREMENT,
` u_name` VARCHAR(50) DEFAULT NULL,
`tinyint1`TINYINT(1),
`tinyint2`TINYINT(2) ZEROFILL,
`tinyint3`TINYINT(3) ZEROFILL,
`tinyint4`TINYINT(4)ZEROFILL,
PRIMARY KEY (`u_id` )
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
INSERT INTO test(u_name,tinyint1,tinyint2,tinyint3,tinyint4)VALUES('zerofill is to fill the default space with 0',6,6,6,6);
SELECT * FROM test;
The difference between Mysql tinyint and Sqlserver tinyint, the use of zerofill
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326577236&siteId=291194637
Recommended
Ranking