数据库的创建 CREATE DATABASE database_name ON PRIMARY (NAME=logical_file_name, filename=‘os_file_name‘, SIZE=size, MAXSIZE=maxsize, FILEGROWTH=growth_increment) --Filegroup f1 --(NAME=logical_file_othername..........)指定多个数据文件 log on (name=logical_file_name, filename=‘os_file_name‘, size=size, MAXSIZE=maxsize, FILEGROWTH=growth_increment) --(name=.....)制定多个事务日志文件
--创建表 create table students ( UserName varchar(20) primary key, --建主键. Password varchar(20) not null, --不能为空值. Name varchar(20) unique, --建惟一键. Sex bit default 1, --建默认约束(缺省约束). Birthday datetime check(birthday>‘1900-1-1‘) --建检查约束. ) --修改表 alter table 表名 Add 列名 列类型 --添加 alter table students drop column Money --删除 alter table students alter column Money Real --修改 --删除表 drop table students
| 段类型 | 描述 | |
| 整数 | bit | 0或1的整型数字 |
| int | 从-2^31(-2,147,483,648)到2^31-1(2,147,483,647)的整型数字 | |
| smallint | 从-2^15(-32,768)到2^15-1(32,767)的整型数字 | |
| tinyint | 从0到255的整型数字 | |
| 精确小数 | decimal(p,s) | 从-10^38到10^38-1的定精度与有效位数的数字 精度p 宽度s |
| numeric(p,s) | decimal的同义词 | |
| 近似小数 | float | 从-1.79E+308到1.79E+308可变精度的数字 |
| real | 从-3.04E+38到3.04E+38可变精度的数字 | |
| 货币 | money |
从-2^63(-922,337,203,685,477.5808)到2^63-1(922,337,203,685,477.5807)的货币数据, 最小货币单位千分之十,宽度4 |
| smallmoney |
从-214,748.3648到214,748.3647的货币数据, 最小货币单位千分之十,宽度4 |
|
| 日期时间 | datetime |
从1753年1月1日到9999年12日31的日期和时间数据, 最小时间单位为百分之三秒或3.33毫秒 |
| smalldatetime |
从1900年1月1日到2079年6月6日的日期和时间数据, 最小时间单位为分钟 |
|
| 特殊数据类型 | timestamp | 时间戳,一个数据库宽度的唯一数字 |
| Cursor | 对游标的引用 | |
| uniqueidentifier | 全球唯一标识符GUID | |
| 字符数据 | char | 定长非Unicode的字符型数据,最大长度为8000 |
| varchar | 变长非Unicode的字符型数据,最大长度为8000 | |
| text | 变长非Unicode的字符型数据,最大长度为2^31-1(2G) | |
| Unicode | nchar | 定长Unicode的字符型数据,最大长度为8000 |
| nvarchar | 变长Unicode的字符型数据,最大长度为8000 | |
| ntext | 变长Unicode的字符型数据,最大长度为2^31-1(2G) | |
| 二进制数据 | binary | 定长二进制数据,最大长度为8000 |
| varbinary | 变长二进制数据,最大长度为8000 | |
| image | 变长二进制数 |
原文:http://www.cnblogs.com/hanke123/p/4957637.html