问题描述:当父表有子表的外键约束时,无法直接truncate父表.报ORA-02266: unique/primary keys in table referenced by enabled foreign keys.这里使用另一种办法来解决这个问题:先把外键失效,truncate表之后再把外键生效.SQL> truncate table machine_room;truncate table machine_room *ERROR at line 1:ORA-02266: unique/pri
--/第1步**********删除所有表的外键约束*************************/ DECLARE c1 cursor for select 'alter table ['+ object_name(parent_obj) + '] drop constraint ['+name+']; ' from sysobjects where xtype = 'F' open c1 declare @c1 varchar(8000) fetch next from c1 int
create table UserType ( Id ,), Name nvarchar() not null ) go create table UserInfo ( Id ,), LoginPwd varchar() not ) not ) not check(Gender= or Gender=), Email varchar() not ) not ) default '这个人很懒,什么都没有留下', UserTypeId int foreign key references UserT