0
votes

I have created an oracle table with this command: 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);

Then I tried to get the constraints with this command: SELECT * FROM user_constraints where TABLE_NAME = 'MyTable';

But the select only returns an empty result? What did I wrong? Or can this happen because of insufficient permissions?

Thanks

1
Are you matching the camel case of your table name, but didn't create it with a quoted identifier? (Which is good; quoted identifiers are a pain, but the table/object name defaults to upper case for unquoted identifiers). It's hard to tell if you've changed the names for your question.Alex Poole

1 Answers

1
votes

Be sure that the table has been created in the same schema you're using to execute the query. You can also check ALL_CONSTRAINTS table. Also, by defaults tables names are saved with only uppercase characters and string comparisons in Oracle are case sensitive. If you did everything right this one should do the trick.

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