数据库_基础代码<sql>
来源:互联网 发布:经常疲劳知乎 编辑:程序博客网 时间:2024/06/08 01:36
以table1 <含字段:id,name> 为例:
表
--是否存在
if exists(select 1 from sysobjects where id = object_id('table1'))
--修改表名
alter table1 rename to table2
--添加列
alter table table1 add Status int default 1
--添加列的约束
ALTER TABLE tablename ADD CONSTRAINT DF_tablename_列名 DEFAULT(0) FOR 列名
--修改列
alter table table1 alter column name varchar(50)
--修改列名
alter table table1 column name to name1
--删除列
alert table table1 drop column name
--删除关系
alert table table1 drop constraint GuanXiMing
存储过程
---是否存在
if exists(select 1 from sysobjects where id=object_id(proc1) and xtype='p')
drop procedure proc1
--创建
create procedure proc1
as
decare....
触发器
if exists(select * from dbo.sysobjects where id =object_id('trig1)and objectProperty(id,N'IsTrigger')=1)
drop trigger trig1
--创建
Create Trigger UpdateTrigger_table1
on T_CorrespondentNode
for UPDATE
as
....
- 数据库_基础代码<sql>
- C#语言和SQL Server数据库技术_数据库查询基础
- 黑马程序员_数据库基础
- Mysql数据库_ 视图.sql
- Mysql数据库_索引.sql
- 数据库系统概念_代码
- 转:[SQL]分离数据库_附加数据库_创建数据库
- sql server 数据库基础
- SQL Server数据库基础
- 数据库sql基础题
- SQL数据库开发基础
- 数据库sql基础
- SQL数据库 基础
- SQL数据库优化--基础
- 数据库--SQL架构基础
- SQL Server 数据库基础
- SQL server数据库基础
- SQL数据库入门基础
- struct的乱序初始化--linux内核源码常用方法
- Spring 系列: Spring 框架简介
- DomainUpDown与NumericUpDown
- UVA 10474 用栈重排字母
- Ftp命令行传文件
- 数据库_基础代码<sql>
- Java Graphics_12
- CRT detected that the application wrote to memory after end of heap buffer
- jquery的一些基本的用法
- applicationWillResignActive
- python gearman的应用
- 使用JCharDet,获得文件的字符集编码!
- js中cookie的添加,删除,查询
- 有关Mat的函数