oracle删表视图索引,怎样删除表以及与其相关的索引和视图

CASCADE CONSTRAINTS

Specify CASCADE CONSTRAINTS to drop all referential integrity constraints that refer to primary and unique keys in the dropped table. If you omit this clause, and such referential integrity constraints exist, then the database returns an error and does not drop the table.

SUNDOG315>create table t_p (id integer,text varchar2(20));

表已创建。

SUNDOG315>alter table t_p add constraints t_p_pk primary key(id);

表已更改。

SUNDOG315>create table t_c(id integer,child_text varchar2(20));

表已创建。

SUNDOG315>alter table t_c add constraints t_c_fk foreign key(id) references t_p(

id);

表已更改。

SUNDOG315>select constraint_name,constraint_type from user_constraints;

CONSTRAINT_NAME                C

------------------------------ -

T_C_FK                         R

T_P_PK                         P

SUNDOG315>drop table t_p;

drop table t_p

*

第 1 行出现错误:

ORA-02449: 表中的唯一/主键被外键引用

SUNDOG315>drop table t_p cascade constraints;

表已删除。

SUNDOG315>desc t_p

ERROR:

ORA-04043: 对象 t_p 不存在

SUNDOG315>desc t_c

名称                                      是否为空? 类型

----------------------------------------- -------- ----------------------------

ID                                                 NUMBER(38)

CHILD_TEXT                                         VARCHAR2(20)

SUNDOG315>select constraint_name,constraint_type from user_constraints;

未选定行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值