简体   繁体   中英

Will I lose any data when changing smallint to int in SQL Db? Is it just a size storage issue?

I have a database that uses an access front-end. The users have asked to change the data that is entered in one column to incorporate a larger number over the Small INT (32,767) size. If i were to change the type to Int is there likely to be any loss of data or any other issues?

Since both the datatypes are of similar types, you won't face any issues. And you're changing from small int to INT(larger number storage), so there won't be any loss of data.

@Ste Willis, from my personal experience, it shouldn't have any effect really other than creating more room to hold much bigger values. So it should be advantageous rather than otherwise. SQL Server INT Data Types are BIGINT, INT, SMALLINT, TINYINT

BIGINT  -263 (-9,223,372,036,854,775,808) to 263-1 (9,223,372,036,854,775,807)  8 Bytes
INT -231 (-2,147,483,648) to 231-1 (2,147,483,647)  4 Bytes
SMALLINT    -215 (-32,768) to 215-1 (32,767)    2 Bytes
TINYINT 0 to 255    1 Byte

This means int is much bigger in size than smallint (atleast twice as big), so changing from smallint to int should not make you lose any data instead it creates more room for more data.

If you were to do the opposite, say from int to smallint, then you may lose data.

I stand to be corrected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM