`

Database Trigger Use

Go 
阅读更多

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

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

**************************************************************************/
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....

    Oracle Database 10g PL-SQL Programming

    ### Oracle Database 10g PL/SQL Programming #### 1. Introduction to PL/SQL PL/SQL (Procedural Language for SQL) is a procedural extension to SQL that provides a powerful way to manipulate data within...

    SQL sever 实训

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

    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 ...

    触发器讲解

    USE database_name; GO SELECT * FROM sysobjects WHERE xtype = 'TR' ``` 查看特定触发器的定义: ```sql EXEC sp_helptext 'trigger_name' ``` 修改触发器的语句类似创建,需指定 `ALTER` 关键字: ```sql ALTER ...

    mysql命令大全mysql命令大全

    要选择一个已存在的数据库,可以使用`USE database_name;`命令,如`USE mydb;`。 3. **查看数据库** 使用`SHOW DATABASES;`命令可以列出所有可用的数据库。 4. **创建数据库** 使用`CREATE DATABASE database_...

    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 ...

    mysql必知必会脚本

    USE my_database; CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL, email VARCHAR(100) UNIQUE NOT NULL ); ``` 这里,`my_database`是创建的数据库,`users`是创建的...

    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 ...

    Quartz2.2.1java任务持久(mysql)存储demo以及资料

    org.quartz.dataSource.myDS.URL = jdbc:mysql://localhost:3306/your_database?useSSL=false&serverTimezone=UTC org.quartz.dataSource.myDS.user = your_username org.quartz.dataSource.myDS.password = your_...

    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 ...

    SQL语言语法基础

    - **选择数据库**:使用`USE`语句切换到特定数据库,例如`USE MyDatabase;` - **删除数据库**:`DROP DATABASE`语句用于删除不再需要的数据库,如`DROP DATABASE MyDatabase;` 2. 表操作: - **创建表**:`...

    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 • ...

Global site tag (gtag.js) - Google Analytics