当前位置:网站首页>SQL Server(设计数据库--存储过程--触发器)
SQL Server(设计数据库--存储过程--触发器)
2022-08-01 22:21:00 【TL。】
--创建默认值
create default moren as 500
go
--创建规则
create rule newrule as @value between 100 and 150
go
--为表的列绑定默认值
sp_bindefault moren,'dbo.orders.OrderNum'
go
--为表的列绑定规则
sp_bindrule newrule,'dbo.orders.OrderNum'
go
--为表的列解绑默认值
sp_unbindefault 'dbo.orders.OrderNum'
go
--为表的列解绑规则
sp_bindrule newrule,'dbo.orders.OrderNum'
go
--删除默认值
drop default moren
go
--删除规则
drop rule newrule
go
--添加自定义类型
sp_addtype newtype,'char(500)',null
go
--删除自定义类型
drop type newtype
go
--创建视图
create view newview as select * from dbo.city
go
--删除视图
drop view newview
go
--创建存储过程
create proc procname as select OrderNum,ProdNum from dbo.items
go
--并执行存储过程
exec procname
go
--重命名 旧名--新名
sp_rename procname,newname
go
--删除存储过程
drop proc newname
go
--查看系统内所有的触发器列表
select * from sysobjects where xtype='tr'
go
--触发器
--newtrigger触发器名字 --在dbo.orders表里的OrderNum列发生update更新事件就输出
create trigger newtrigger on dbo.orders for update as if update(OrderNum)
print'订单号码已被更改,触发器起到作用'
go
update dbo.orders set OrderNum='133' where OrderNum=101
边栏推荐
- NgRx Selector 的 Memoization 特性学习笔记
- 线上故障排查方案
- 如何防范 DAO 中的治理攻击?
- Go 微服务开发框架DMicro的设计思路
- 【牛客刷题-SQL大厂面试真题】NO4.出行场景(某滴打车)
- Ten years after graduation, financial freedom: those things that are more important than hard work, no one will ever teach you
- 小程序毕设作品之微信美食菜谱小程序毕业设计成品(8)毕业设计论文模板
- How to add a game character to a UE4 scene
- 递归(各经典例题分析)
- Raspberry Pi information display small screen, display time, IP address, CPU information, memory information (C language), four-wire i2c communication, 0.96-inch oled screen
猜你喜欢
工程建筑行业数据中台指标分析
不卷了!入职字节跳动一周就果断跑了。
【C语言实现】两种计算平均成绩题型,博主精心整理,值得一读
小程序毕设作品之微信体育馆预约小程序毕业设计成品(3)后台功能
2022 版 MySQL 巅峰教程,收藏好,慢慢看
联邦学习在金融领域的发展和应用
render-props and higher order components
小程序毕设作品之微信体育馆预约小程序毕业设计成品(1)开发概要
2022 edition of MySQL tutorial, top collection good, take your time
Analysis of the development trend of game metaverse
随机推荐
[ASM] Bytecode Operation MethodWriter
今日睡眠质量记录74分
Graph Theory - Strongly Connected Component Condensation + Topological Sort
leetcode刷题
毕业十年,财富自由:那些比拼命努力更重要的事,从来没人会教你
如何理解 new (...args: any[]) => any
小程序容器+自定义插件,可实现混合App快速开发
Implementation principle of VGUgarbage collector (garbage collector)
render-props and higher order components
高等代数_证明_矩阵的行列式为特征值之积, 矩阵的迹为特征值之和
如何防范 DAO 中的治理攻击?
论文解读(GSAT)《Interpretable and Generalizable Graph Learning via Stochastic Attention Mechanism》
[机缘参悟-58]:《素书》-5-奉行仁义[遵义章第五]
User Experience | How to Measure User Experience?
解决 win10 下 ISE14.7的 iMPACT 崩溃问题 - FPGA 笔记
[深入研究4G/5G/6G专题-48]: 5G Link Adaption链路自适应-4-下行链路自适应DLLA-PDCCH信道
小程序毕设作品之微信体育馆预约小程序毕业设计成品(4)开题报告
2022年最新河北建筑八大员(机械员)模拟考试题库及答案
线上故障排查方案
【ASM】字节码操作 MethodWriter