accessd
accessd

Reputation: 93

What difference between NULL and NULL::character varying in PostgreSQL

Is there a difference between default values of column in PostgreSQL? Whether this is important?

state character varying(255) DEFAULT NULL

and

state character varying(255) DEFAULT NULL::character varying

Upvotes: 9

Views: 10696

Answers (1)

Erwin Brandstetter
Erwin Brandstetter

Reputation: 658162

There is no effective difference in the presented example in a standard installation.

Without explicit cast, NULL of data type unknown will be coerced to varchar in an assignment cast automatically. See:

In other situations, where the type cannot be derived from context, you may need to cast explicitly - to tell Postgres the intended type of the value. This is rarely the case, though.

Upvotes: 9

Related Questions