最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
mssql中修改字段默认值default value
时间:2013-11-21 编辑:简简单单 来源:一聚教程网
1、取得数据库所有表的默认值:
代码如下 | 复制代码 |
t3.name as 表名,t1.name as 字段名,t2.text as 默认值 ,t4.name from syscolumns t1,syscomments t2,sysobjects t3 ,sysobjects t4 where t1.cdefault=t2.id and t3.xtype=’u’ and t3.id=t1.id and t4.xtype=’d’ and t4.id=t2.id; |
2、生成删除所有默认值的语句:
代码如下 | 复制代码 |
select “ALTER TABLE ” + t3.name + ” DROP CONSTRAINT ” +t4.name +”;” from syscolumns t1,syscomments t2,sysobjects t3 ,sysobjects t4 where t1.cdefault=t2.id and t3.xtype=’u' and t3.id=t1.id and t4.xtype=’d' and t4.id=t2.id ; |
3、生成批量添加所有默认值的语句:
代码如下 | 复制代码 |
select “alter table ” + t3.name + “ add default (1) for ” +t1.name +”;” from syscolumns t1,syscomments t2,sysobjects t3 ,sysobjects t4 where t1.cdefault=t2.id and t3.xtype=’u' and t3.id=t1.id and t4.xtype=’d' and t4.id=t2.id ; |
-
上一个: oracle tde透明数据加密用法详解
相关文章
- MySQL登录、访问及退出操作解析 10-18
- sql语句 update字段null不能用is null问题解析 09-28
- SQL Server ISNULL 不生效原因及解决分析 09-28
- 关于if exists的用法及说明分析 09-28
- Access数据库日常维护方法 09-28
- Oracle 删除大量表记录操作介绍 09-27