功能:在删除主表时,自动删除副表(外键约束)相应内容
删除包含主键值的行的操作,该值由其它表的现有行中的外键列引用。在级联删除中,还删除其外键值引用删除的主键值的所有行。
如:
create database temp
go
use temp
go
create table UserInfo
(
UserId int identity(1,1) primary key ,
UserName varchar(20),
password varchar(20) not null --密码
)
create table UserDetails
(
id int identity(1,1) primary key,
name varchar(50) not null, --真实姓名
userId int,
foreign key (userId) references UserInfo(UserId) on delete cascade
)
insert UserInfo values ('ly','jeff')
insert UserInfo values('wzq','wzqwzq')
insert UserInfo values('lg','lglg')
insert UserDetails values('李四',1)
insert UserDetails values('王五',2)
insert UserDetails values('刘六',3)
sqlserver 支持级联更新和删除
oracle 只支持级联删除
alter table 表名
add constraint 外键名
foreign key(字段名) references 主表名(字段名)
on delete cascade
语法:
Foreign Key
(column[,...n])
references referenced_table_name[(ref_column[,...n])]
[on delete cascade]
[on update cascade]
注释:
column:列名
referenced_table_name:外键参考的主键表名称
ref_name:外键要参考的表的主键列
on delete:删除级联
on update:更新级联
关闭子页面,刷新父页面
动态控制DataGrid中的TextBox的状态及输入值!!
C#对Oracle BLOB字段的写入读取方法
谈恋爱,好累...
可移植,可扩展高效Proactor模式
When are asynchronous file writes not asynchronous...
[转]How to support 10,000 or more concurrent TCP connections
[转]Creating a forwarding dll
[转]非金钱激励员工的108种手段