3

Is there any difference between varchar2 in oracle sql and pl/sql or both are same or there are some implementation difference.

1 Answer 1

4

There is at least one difference: the length.

in Pl/sql, it can have a maximum length of 32,767 bytes, while in sql it can only be 4,000 bytes long.

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

3 Comments

This is true for Oracle versions up to 11gR2. Starting with 12c, maximum length of Varchar2 in SQL is also 32767 bytes, see docs.oracle.com/cd/E16655_01/server.121/e17906/chapter1.htm
Thanks Frank, didn't know that yet. Guess I should brush up my Oracle skills a bit.
Another difference is memory allocation: "For a CHAR variable, or for a VARCHAR2 variable whose maximum size is less than 2,000 bytes, PL/SQL allocates enough memory for the maximum size at compile time. For a VARCHAR2 whose maximum size is 2,000 bytes or more, PL/SQL allocates enough memory to store the actual value at run time. In this way, PL/SQL optimizes smaller VARCHAR2 variables for performance and larger ones for efficient memory use." Although this probably only matters if you're misusing PL/SQL.

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.