无法在 oracle 中找到约束

Cant find constraint in oracle

我用这个命令创建了一个 oracle table: create Table MyTable(Nr Integer not null, Name VARCHAR(50), CONSTRAINT PK_MyTable Primary key(Nr)) tablespace USERS storage (initial 4K next 4K minextents 2 maxextents 50 pctincrease 0);

然后我尝试使用此命令获取约束: SELECT * FROM user_constraints 其中 TABLE_NAME = 'MyTable';

但是select只是returns一个空的结果?我做错了什么?或者这可能是因为权限不足导致的?

谢谢

确保 table 是在您用于执行查询的同一架构中创建的。您还可以查看 ALL_CONSTRAINTS table。 此外,默认情况下 tables 名称仅使用大写字符保存,并且 Oracle 中的字符串比较区分大小写。如果您做对了所有事情,那么这个应该就可以了。

SELECT * FROM user_constraints where TABLE_NAME = UPPER('MyTable');