摘要:
/*用触发器来实现级联更新级联删除*/
--创建学生表,课程表,学生课程表
--http://www.yaosansi.com/post/692.html
范本:
触发器方式:
create trigger trg_A
on A
for update,delete
as
begin
if exists(select 1 from inserted)
update B set Name=(select Name from inserted) where Name=(select Name from deleted)
else
delete B where Name=(select Name from deleted)
end
go
下面是一个实例:
CREATE TABLE [dbo].[学生表](
[studentid] [nvarchar](50) primary key NOT NULL,
[name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
)
CREATE TABLE [d 阅读全文
posted @ 2010-05-21 21:25
叮当小马
阅读(13500)
评论(0)
推荐(1)
摘要:
参考网站:
http://www.phpchina.com/manual/PostgreSQL/ddl-constraints.html
/*
创建级联更新,级联删除操作
author: dingdang
time :20100520
**/
--创建表
CREATE TABLE products (
product_no integer PRIMARY KEY,
name text,
price numeric
);
CREATE TABLE orders (
order_id integer PRIMARY KEY,
shipping_address text,
-- ...
);
/*
CREATE TABLE order_items (
阅读全文
posted @ 2010-05-21 21:19
叮当小马
阅读(2592)
评论(0)
推荐(1)