---
title: "SQL Server的tinyint有个坑啊"
author: "swordinhand"
date: "2014-01-17T11:42:55Z"
tags: ["MySQL", "SQL Server", "tinyint"]
categories: ["数据库"]
slug: "sql-server-tinyint"
draft: false
lastmod: "2014-01-17T11:42:55Z"
id: 2005584
url: "https://swordinhand.iteye.com/blog/2005584"
---

      根据微软官方文档 http://technet.microsoft.com/zh-cn/library/ms187745.aspx，SQL Server支持bignt, int, smallint, tinyint这四种int，前三种都是有符号的，而tinyint却是无符号的，取值范围是0-255，而Mysql里面，tinyint默认是有符号的，取值范围是-128到127，unsigned tinyint才是0-255，如果在这两个数据库直接迁移表结构的话，就要注意了。