SQL触发器 禁用 启动

心已入冬 提交于 2020-01-11 10:49:55

 

 

https://www.cnblogs.com/FlyGoldfish/articles/6398212.html

 

 

 

 

 

#
def starttrigger():# enable 启动 # disable 关闭
    conn, cursor=get57sql()
    starttrigger_sql="alter table [PersonHouseInfo].[dbo].[student2] enable   trigger trig_delete"
    cursor.execute(starttrigger_sql)
    conn.commit()
# 创建触发器
def createtrigger():
    conn, cursor = get57sql()
    createtrigger_sql="Create trigger  [dbo].[trig_delete] on [dbo].[student2] after delete as begin select stu_id as  已删除的学生编号,stu_name, stu_gender, stu_age  from deleted end;"
    cursor.execute(createtrigger_sql)
    conn.commit()


# 删除触发器
def droptrigger():
    conn, cursor = get57sql()
    droptrigger_sql="drop trigger trig_delete"
    cursor.execute(droptrigger_sql)
    conn.commit()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!