9

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

1 Answer 1

9

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.