Skip to Main Content

SQL & PL/SQL

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!

PK and NOT NULL on one column -effect on performance

Jana KralovaMay 27 2011 — edited May 27 2011
Hello everybody,



we have quite big database and I've been going through some old tables and found something really strange.

Many tables are written as:




CREATE TABLE log (



    id NUMBER(16) NOT NULL



        CONSTRAINT pk_log PRIMARY KEY



    .....
Since PK itself contains NOT NULL condition, I think that the NN constraint really isn't necessary.

We didn't have versioning control at the time so I cannot find out who - and what I really want to know is why - did this and those people are probably not in the company anymore.



I need an advice on:



1. Is there any advantage on writting a CREATE TABLE statement this way?

I think it's rubbish and I searched the documentation and didn't find a thing.

Am I missing something?



I queried user_cons_columns and two constraints are created.

Writting a block of code that would drop all NN constraints from columns where PK exists is not a problem, but I would have to open every script and modify create table stmt, which would be quite consuming. So I really need to know



2. Is there any negative impact on performance???
If yes, then please clarify a bit why?


Thanks in advance for all replies.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 24 2011
Added on May 27 2011
6 comments
493 views