Do we need to specify “not null” for primary key? Oracle/SQL [closed]

create table mytable (
  col1 number primary key,
  col2 number,
  col3 number not null
);

table MYTABLE created.

select table_name, column_name, nullable 
from user_tab_cols where table_name="MYTABLE";

TABLE_NAME                     COLUMN_NAME                    NULLABLE
------------------------------ ------------------------------ --------
MYTABLE                        COL1                           N        
MYTABLE                        COL2                           Y        
MYTABLE                        COL3                           N        

So, no, you do not need to specify primary key columns as NOT NULL.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)