Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying the constraints in a table

Hello I am trying to display the constraints in one of my tables but for some reason I get the message no rows selected. Noted below is the table I have created.

Create table Teams (
   TeamID varCHAR2(4) constraint Teams_TeamID_PK Primary Key,
   TeamName VARCHAR2(40) 
);

This is the code I am using to show my constraints.

SELECT constraint_name, 
       constraint_type,
       search_condition
  FROM USER_CONSTRAINTS
 WHERE table_name = 'Teams';

I am a rookie so I want to make sure I understand what is wrong. I have tried to drop the table thinking that my constraints did not take - I did not, nor did I receive any errors when I created the table and I am referencing TeamID in another table. So when I try to drop the table I get an error message when is what I was hoping for.

like image 524
Michael Avatar asked Dec 03 '09 05:12

Michael


1 Answers

Try this:

SELECT constraint_name, 
       constraint_type,
       search_condition
  FROM USER_CONSTRAINTS
 WHERE table_name = 'TEAMS';

Unless double-quoted when created, all object names in Oracle are upper case.

like image 91
DCookie Avatar answered Oct 04 '22 15:10

DCookie