`

Database Trigger Use

阅读更多

/**************************************************************************

    说明:  通过触发器进行排除插入已存在的用户名的的操作

**************************************************************************/
CREATE TRIGGER trigger_student_insert
ON student
AFTER INSERT
AS
    IF EXISTS(SELECT * FROM student,inserted WHERE student.stuName=inserted.stuName)
BEGIN
    print 'name is san exist'
    rollback transaction
END


insert into student values('tong',1,getDate(),'guangzhou')

/**************************************************************************

    说明:  通过触发器进行排除插入分数大于100的操作

**************************************************************************/

USE school
GO
CREATE TRIGGER trigger_result_insert
ON result
AFTER INSERT
AS
    IF(SELECT mark FROM student,inserted WHERE student.stuId=inserted.stuId)>100
BEGIN
    print 'not insert mark > 100'
    rollback transaction
END


INSERT INTO result values(3,3,101).

分享到:
评论

相关推荐

    OpenShift for Developers

    Trigger an automatic rebuild and redeployment when you push changes to the repository Get a working environment up in minutes with application templates Use commands to check and debug your ...

    IBExpert 2009.03.25

    Performance Analysis, SQL Monitor, Database Statistics, Recompute Selectivity of all Indices, Recompile Procedures and Triggers, global Stored Procedure/Trigger Operations Index analysis etc....

    Direct Oracle Access 4.1.2 Full Source for Delphi 2010

    w Make use of server generated values (defaults, trigger modified columns) w Query By Example mode for high performance queryable forms without any programming w Use PL/SQL blocks for server logic in...

    EMS SQL Manager 2008 for Interbase Firebird 5.1.0.1.part1

    SQL Manager 2005 is compatible with any Firebird version up to 2.0 and InterBase version up to 7.5 and supports all of the latest features including trigger messages, BLOB filters, and so on....

    EMS SQL Manager 2008 for Interbase Firebird 5.1.0.1.part2

    SQL Manager 2005 is compatible with any Firebird version up to 2.0 and InterBase version up to 7.5 and supports all of the latest features including trigger messages, BLOB filters, and so on....

    微软内部资料-SQL性能优化3

    An isolation level determines the degree to which data is isolated for use by one process and guarded against interference from other processes. Prior to SQL Server 7.0, REPEATABLE READ and ...

    SQLPrompt_7.3.0.775

    Scripts that create or alter a procedure or trigger (UserVoice) TRUNCATE statements Format actions for aliases Add/remove AS keyword on alias definition for tables and views (UserVoice) Apply column ...

    Percona-XtraDB-Cluster

    Percona XtraDB Cluster is a database clustering solution for MySQL. It ensures high availability, prevents downtime and data loss, and provides linear scalability for a growing environment. Features ...

    SQL Assistant v5.0

    You can now configure additional symbols that trigger automatic column name popups, for example, you may add <, , >, BETWEEN and other symbols to trigger automatic column popup display. SQL ...

    pentaho-kettle-master.zip

    Optionally you can specify -Drelease to trigger obfuscation and/or uglification (as needed) Optionally you can specify -Dmaven.test.skip=true to skip the tests (even though you shouldn't as you ...

    filemaker 12 in depth

    • Trigger automated behaviors whenever specific events occur • Extend FileMaker’s functionality with plug-ins • Set up, configure, tune, and secure FileMaker Server All In Depth books offer • ...

    SQL sever 实训

    CREATE TRIGGER UPDATE_ProNo_Stocks_TRIGGER ON Product FOR UPDATE AS PRINT'已即时更新每种产品的库存数量' GO --使用IF UPDATE(column)尽可能优化上题的触发器,以提高系统效率 ALTER TRIGGER ...

    spring-boot-reference.pdf

    Using a Trigger File 20.2.6. Customizing the Restart Classloader 20.2.7. Known Limitations 20.3. LiveReload 20.4. Global Settings 20.5. Remote Applications 20.5.1. Running the Remote Client ...

    IBO v5.3.3 Build 1955(January 2, 2014) Full Source

    I totally reworked the NT Service app sample application into a 100% functional application that shows you how to replicate a portion of a table into a separate database and how to put a full text ...

    SQL2005课程设计

    create database SQL0911061212 on primary ( name='TEST0DATA1',filename='D:\\MyTest\\TEST0DATA1.mdf', size=4,maxsize=20,filegrowth=1 ), filegroup TESTDATA2 ( name='TEST0DATA2',filename='D:\\MyTest\\...

    CE中文版-启点CE过NP中文.exe

    structure data from PDB files can now be used, and are stored in a database for lookup later dissect structures form can now show a list of known structures (pdb, mono, ...) Added a "revert to saved ...

    libae:一个简单的事件库

    The library drive from Redis database source.please respect the author copyright of Redis.you can use the library as you want. The library just supports epoll and select event-trigger,and I will add ...

    计算机网络第六版答案

    First, the content provider has more control over the user experience, since it has to use few intermediary ISPs. Second, it can save money by sending less traffic into provider networks. Third, if ...

    SQL21日自学通

    The Use of Public Synonyms in a Multischema Database488 The Dreaded Cartesian Product 488 Failure to Enforce File System Structure Conventions 489 Allowing Large Tables to Take Default Storage ...

    Beginning Python (2005).pdf

    Deciding When to Use DBM and When to Use a Relational Database 255 Working with Relational Databases 255 Writing SQL Statements 257 Defining Tables 259 Setting Up a Database 260 Try It Out: ...

Global site tag (gtag.js) - Google Analytics