Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Find tables without primary keys

Ken_73Aug 16 2016 — edited Aug 16 2016

DB version: 11.2.0.4

In my business schema, there are several tables without primary keys. Is there a straightforward way to find all these tables ?

For tables without primary key, USER_CONSTRAINTS view will have no entry. So, USER_CONSTRAINTS is of no use to me. Any other way ?

SQL> desc user_constraints

Name                                      Null?    Type

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

OWNER                                              VARCHAR2(120)

CONSTRAINT_NAME                           NOT NULL VARCHAR2(30)

CONSTRAINT_TYPE                                    VARCHAR2(1)

TABLE_NAME                                NOT NULL VARCHAR2(30)

SEARCH_CONDITION                                   LONG

R_OWNER                                            VARCHAR2(120)

R_CONSTRAINT_NAME                                  VARCHAR2(30)

DELETE_RULE                                        VARCHAR2(9)

STATUS                                             VARCHAR2(8)

DEFERRABLE                                         VARCHAR2(14)

DEFERRED                                           VARCHAR2(9)

VALIDATED                                          VARCHAR2(13)

GENERATED                                          VARCHAR2(14)

BAD                                                VARCHAR2(3)

RELY                                               VARCHAR2(4)

LAST_CHANGE                                        DATE

INDEX_OWNER                                        VARCHAR2(30)

INDEX_NAME                                         VARCHAR2(30)

INVALID                                            VARCHAR2(7)

VIEW_RELATED                                       VARCHAR2(14)

SQL> create table tb12 (col1 varchar2(22), col2 varchar2(35));

Table created.

SQL> select * from user_constraints;

no rows selected

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 13 2016
Added on Aug 16 2016
5 comments
1,219 views