Pregunta

Me refiero específicamente sobre int sin firmar.

Este es un ejemplo práctico: ¿qué hacer cuando su columna de identidad maxes? Es posible, ya sea BigInt Go (8 bytes de almacenamiento en lugar de 4) o refactorizar la aplicación para apoyar enteros negativos, e incluso para crear sus propias reglas como se indica en esta respuesta ; ninguna de estas opciones son óptimas.

UInt sería una solución ideal, pero SQL Server no ofrecerlo (donde hace MySQL).

Yo entiendo que los tipos de datos sin signo no son parte del estándar SQL (SQL-2003), pero todavía parece una pérdida para mí.

¿Cuál es la razón de no incluir estos (en SQL Server o en la norma)?

¿Fue útil?

Solución

If I had to guess, I would say that they are trying to avoid a proliferation of types. Generally speaking there isn't anything that an unsigned integer can do that a signed integer can't do. As for the case when you need a number between 2147483648 and 4294967296 you probably should go to an 8 byte integer since the number will also eventually exceed 4294967296.

Otros consejos

For that purpose you could use -2,147,483,648 as the seed value.

Identity(-2147483648, 1)

I found a similar question on Microsoft Connect.

The reply from Jim Hogg (Program Manager) has some pro's and con's for adding unsigned int's. The major con is the rules to implement implicit type conversions become a nightmare to get right.

The request was closed as "Won't Fix".

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top