SQLServer模板大全

目 录

1.创建数据库SQL语言: ................................... 5 2.分离数据库SQL语言: .................................... 5 3.附加数据库SQL语言: ................................... 6 4.修改数据库数据文件容量SQL语言: ....................... 6 5.修改数据库日志文件容量SQL语言: ....................... 6 6.向数据库中添加文件SQL语言: ........................... 6 7.删除数据库中文件SQL语言: ............................. 7 8.修改数据库名SQL语言: ................................. 7 9.查看数据库文件信息: ................................... 7 10.查看数据库信息: ...................................... 7 11.收缩数据库: .......................................... 8 12.收缩数据库文件: ...................................... 8 13.删除数据库: .......................................... 8 14.创建表: .............................................. 8 15.修改表 ................................................ 9 16.修改列定义: .......................................... 9 17.修改列名: ............................................ 9 18.删除列: .............................................. 9 19.修改表名: ........................................... 10 20.删除表: ............................................. 10 21.创建主键约束: ........................................ 10 22.创建外键约束: ........................................ 11 23.创建唯一约束: ........................................ 13 24.创建check约束: ...................................... 14 25.创建默认值约束: ...................................... 15 26.查看约束: ............................................ 16 27.删除约束: ............................................ 16 28.简单查询 ............................................. 16

29.查询时生成新表 ....................................... 16 30.交叉连接查询 ......................................... 17 31.内连接查询 ........................................... 17 32.外连接 ............................................... 17 33.自连接 ............................................... 18 34.联合查询 ............................................. 18 35.子查询 ............................................... 18 36.向表中插入语句 ....................................... 19 37.修改表数据 ........................................... 19 38.删除表数据 ........................................... 20 39.创建视图 ............................................. 20 40.修改视图 ............................................. 21 41.查看视图定义信息 ..................................... 21 42.查看视图依赖关系 ..................................... 21 43.删除视图 ............................................. 21 44.重命名视图 ........................................... 21 45.创建聚簇索引: ........................................ 22 46.创建非簇索引: ........................................ 22 47.创建唯一索引: ........................................ 22 48.查看索引: ............................................ 22 49.修改索引名: .......................................... 22 50.删除索引: ............................................ 23 51.声明变量: ............................................ 23 52.变量赋值: ............................................ 23 53.begin ................................................ 23 54.选择语句 ............................................. 23 55.case表达式 .......................................... 24 56.while语句 ........................................... 25 57.创建存储过程 ......................................... 25

58.修改存储过程 ......................................... 25 59.删除存储过程 ......................................... 26 60.带参存储过程 ......................................... 26 61.执行带输入参数存储过程 ............................... 26 62.创建DML触发器 ....................................... 26 63.修改DML触发器 ....................................... 27 64.删除触发器 ........................................... 27 65.禁止触发器 ........................................... 27 66.启用触发器 ........................................... 28 67.查看触发器的定义信息 ................................. 28 68.查看触发器信息 ....................................... 28 69.查看触发器依赖信息 ................................... 28 70.创建DDL触发器 ....................................... 28 71.删除DDL触发器 ....................................... 29 72.创建备份设备 ......................................... 29 73.创建数据库完全备份 ................................... 29 74.创建数据库差异备份 ................................... 29 75.创建日志备份 ......................................... 30 76.文件或文件组备份 ..................................... 30 77.恢复数据库 ........................................... 30 78.恢复日志 ............................................. 30 79.恢复文件或文件组 ..................................... 31 80.恢复部分数据库(即还原指定文件) ....................... 31 81.创建SQL Server身份验证登录帐户 ...................... 31 82.将一个windows系统帐户映射为使用windows身份验证登录帐户 ........................................................ 31 83.禁止登录帐户 ......................................... 32 84.删除登录帐户 ......................................... 32 85.创建服务器角色 ....................................... 32

86.删除服务器角色 ....................................... 32 87.添加数据库用户 ....................................... 32 88.修改数据库用户 ....................................... 33 89.删除数据库用户 ....................................... 33 90.创建数据库角色 ....................................... 33 91.删除数据库角色 ....................................... 33 92.授予权限 ............................................. 33 93.拒绝权限 ............................................. 34 94.取消权限 ............................................. 34 95.分页查询 ............................................. 34

联系客服:779662525#qq.com(#替换为@)