开发者

How can i determine my tables priority order?

开发者 https://www.devze.com 2023-03-27 04:19 出处:网络
I want to organize my tables and make a list for usage. What kind of criteria (dependency, fill factor, read/write rate, record count) can i use? I want to protect my database from deadlock...

I want to organize my tables and make a list for usage. What kind of criteria (dependency, fill factor, read/write rate, record count) can i use? I want to protect my database from deadlock...

For example: at simple, i have four tables in my database

a table : 4 dependencies
b table : 2 dependencies
c table : 2 dependencies
d table : No dependency

If i want t开发者_开发知识库o write a stored procedure, which table used firstly?


C = Check Constraint
D = Default or Default Constraint
F = Foreign Key Constraint
L = Log
Fn = Scalar Function
If = Inlined Table Function
P = Stored Procedure
Pk = Primary Key Constraint
Rf = Replication Filter Stored Procedure 
S = System Table
Tf = Table Function
Tr = Trigger
U = User Table
Uq = Unique Constraint 
V = View

SELECT DISTINCT SysObjects.Name 'Table Name', 
                Procedures.Name 'Stored Procedure'
           FROM SysObjects 
           JOIN (SysObjects Procedures    
           JOIN SysDepends     
             ON Procedures.Id = SysDepends.Id) 
             ON SysDepends.DepId = SysObjects.Id
          WHERE SysObjects.XType = 'U'     
-- Change XType Values here using chart above     
            AND Procedures.XType = 'P'
       GROUP BY SysObjects.Name, 
                SysObjects.Id, 
                Procedures.Name
       ORDER BY SysObjects.Name ASC

Taken from here.

0

精彩评论

暂无评论...
验证码 换一张
取 消