on delete cascade是否级连删除,比如要删除主表中一条记录,如在从表有对应也删除从表中的记录?
declare num1 int; begin select count(*) into num1 from user_tables where table_name ='TEACHING'; if num1>=1 then execute immediate 'drop table TEACHING'; end if; execute immediate 'create table Teaching ( TName char(6), CNo char(4), CTime number(3), CDate char(12), SClass char(7), Primary key(TName, CNo, SClass), Foreign key(CNo) references Course(CNo) on delete cascade )'; end;
oracle 要判断并删除表这么麻烦,如果是多张表那还了得? 请问有没有什么更方便的方法?
判断视图的语句 declare num1 int; begin select count(*) into num1 from user_views where VIEW_NAME ='TEACHING'; if num1>=1 then execute immediate 'drop VIEW_NAME TEACHING'; end if; execute immediate
num1 int;
begin
select count(*) into num1 from user_tables where table_name ='TEACHING';
if num1>=1
then
execute immediate 'drop table TEACHING';
end if;
execute immediate
'create table Teaching
(
TName char(6),
CNo char(4),
CTime number(3),
CDate char(12),
SClass char(7),
Primary key(TName, CNo, SClass),
Foreign key(CNo) references Course(CNo) on delete cascade
)';
end;
请问有没有什么更方便的方法?
declare
num1 int;
begin
select count(*) into num1 from user_views where VIEW_NAME ='TEACHING';
if num1>=1
then
execute immediate 'drop VIEW_NAME TEACHING';
end if;
execute immediate