DB2 Error Code – -542 column name cannot be a column of a primary key or a unique constraint because it can contain null values

In this post, you’ll learn about the error message -542 column name cannot be a column of a primary key or a unique constraint because it can contain null values in the IBM DB2 database , the reason why it occurs along with the solution to fix it

IBM DB2 Error Message

-542 column name cannot be a column of a primary key or a unique constraint because it can contain null values

Reason for the Error

The code is used to report that a column identified in a PRIMARY KEY or a UNIQUE constraint clause is defined to allow null values.

Solution

Correct the statement and rerun it.