我在SQL Server 2012中有2个表的数据库。
表A
aid, (used), max_count
表B
bid, aid, x
表B中的bid
是主键,而aid
是表A的外键。
在表A中,aid
是主键,并且used
是计算列,其计数然后对表B中已使用的aid
进行计数。
我要始终在表A中used
<= max_count
。
如何控制表A上max_count
不小于used
的更新?
如何控制used
不大于max_count
的添加到表B?
答案 0 :(得分:0)
此触发器可用于插入B并更新A。您可能还需要其他触发器来更新B。
#!/usr/bin/env python3
from random import *
Livros = ["Lucas", "Isaias"]
Lucas = ["Lucas1", "Lucas2"]
Isaias = ["Isaias1", "Isaias2"]
Lucas1 = {
"1" : "Text1" ,
"2" : "Text2" ,
"3" : "Text3" ,
"4" : "Text4"
}
Lucas2 = {
"1" : "Text1" ,
"2" : "Text2" ,
"3" : "Text3" ,
"4" : "Text4"
}
Isaias1 = {
"1" : "Text1" ,
"2" : "Text2" ,
"3" : "Text3" ,
"4" : "Text4"
}
Isaias2 = {
"1" : "Text1" ,
"2" : "Text2" ,
"3" : "Text3" ,
"4" : "Text4"
}
x = choice(Livros)
print(x)
xx = choice(x)
print(xx)```