1

我有一个没有表的 Oracle 模式(我删除了它们)。然而,当我看user_constraints表时

    SELECT * FROM user_constraints;

我看到很多行。怎么可能删除这些约束?

    DELETE FROM user_constraints WHERE owner='owner';

没有用,它给了我一个“权限不足”的错误。

    SELECT owner, constraint_name, constraint_type, table_name, r_owner, r_constraint_name  FROM user_constraints;

    OWNER                          CONSTRAINT_NAME                CONSTRAINT_TYPE TABLE_NAME                     R_OWNER                        R_CONSTRAINT_NAME            
    ORA_AI_1_9                     BIN$z2XwnFUHEHrgQ4sGOR4Qeg==$0 P               BIN$z2XwnFUJEHrgQ4sGOR4Qeg==$0                                                               

    ORA_AI_1_9                     BIN$z1NhC6g4oErgQ4sGOR6gSg==$0 P               BIN$z1NhC6g6oErgQ4sGOR6gSg==$0                                                               

    ORA_AI_1_9                     BIN$z1anK5OEEHrgQ4sGOR4Qeg==$0 P               BIN$z1anK5OGEHrgQ4sGOR4Qeg==$0                                                               

    ORA_AI_1_9                     BIN$z1NhC6hhoErgQ4sGOR6gSg==$0 P               BIN$z1NhC6hjoErgQ4sGOR6gSg==$0            
4

3 回答 3

3

那么你在 10/11g 上并且可能有回收站吗?

SQL> select count(*) from user_tables;

  COUNT(*)
----------
         0

SQL> select count(*) from user_constraints;

  COUNT(*)
----------
         0

SQL> create table foo(id number primary key);

Table created.

SQL> ALTER SESSION SET recyclebin = ON;

Session altered.

SQL> select count(*) from user_tables;

  COUNT(*)
----------
         1

SQL> select count(*) from user_constraints;

  COUNT(*)
----------
         1

SQL> drop table foo;

Table dropped.

SQL> select count(*) from user_constraints;

  COUNT(*)
----------
         1

SQL> select count(*) from user_tables;

  COUNT(*)
----------
         0

SQL>

你可以清除 reclebin 来解决这个问题。

SQL> purge recyclebin;

Recyclebin purged.

SQL> select count(*) from user_constraints;

  COUNT(*)
----------
         0
于 2012-11-27T16:44:12.377 回答
1

你可以发表如下声明DROP TABLE [schema.]table_name [CASCADE CONSTRAINTS]

于 2012-11-27T16:31:38.810 回答
0

首先,您永远不应该直接针对数据字典表(如user_constraints.

其次,您是否拥有在其他用户拥有的表上创建的约束?做什么

SELECT owner, constraint_name, constraint_type, table_name, r_owner, r_constraint_name
  FROM user_constraints

返回?

于 2012-11-27T16:33:56.460 回答