国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

分析數據庫的依賴關系

2024-07-21 02:12:45
字體:
來源:轉載
供稿:網友
,歡迎訪問網頁設計愛好者web開發。

有一個非常好的系統存儲過程會幫助你分析數據庫的依賴關系,它就是:sp_depends。這個過程會指出哪些數據庫對象依賴于對應的數據庫對象,和哪些數據庫對象為對應的數據庫對象引用了。

 
    如果所有的對象按依賴順序創建的,那么這個系統存儲過程會更魯棒。那些依賴于其他對象的對象總是在它們引用的對象之后創建的。

       使用這個過程的一個原因是為了確定一個過程或者表的變化的影響。如果你有一個對象,它引用了30個對象,那么很有可能在編碼期間,你為了改變這30個對象而須做更多的工作。

    下面的腳本展示一個存儲過程和一些對象,這個存儲過程引用了一些對象,其他對象又引用了這個存儲過程。

if exists(select name
       from    sysobjects
       where    name = n'test_table'
       and    type = 'u')
    drop table test_table
go
create table test_table (
c1 varchar(255) null)
go
if exists (select name
       from    sysobjects
       where    name = n'test_proc1'
       and    type = 'p')
    drop procedure test_proc1
go
create procedure test_proc1 @name sysname = null
as
if @name is not null
begin
       insert test_table values (@name)
end
else
begin
       return
end
go
if exists (select name
       from    sysobjects
       where    name = n'test_proc2'
       and    type = 'p')
    drop procedure test_proc2
go
create procedure test_proc2
as
declare @myvar sysname
select @myvar = name from sysobjects where id = 1
exec test_proc1 @myvar
go
exec sp_depends test_proc1
go
drop procedure test_proc2, test_proc1
go
drop table test_table
go

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 茶陵县| 定陶县| 黄龙县| 水富县| 吴堡县| 察哈| 兴安县| 武冈市| 宁晋县| 田阳县| 霍林郭勒市| 弥勒县| 庄浪县| 称多县| 洛扎县| 兰坪| 屯门区| 碌曲县| 洞口县| 台南县| 武定县| 肇庆市| 台中市| 定兴县| 庆云县| 宁河县| 县级市| 太湖县| 聂荣县| 邹平县| 汽车| 仲巴县| 墨江| 太康县| 青神县| 亚东县| 辽阳市| 错那县| 马鞍山市| 巴林左旗| 渭南市|