What is the max size of VARCHAR2 in PL/SQL and SQL?

Ajay Gupta picture Ajay Gupta · Aug 11, 2014 · Viewed 199.4k times · Source

I am on Oracle 10g. In a requirement I need to increase the size of a pl/sql VARCHAR2 variable. It is already at 4000 size. I have read that

in PL/SQL, VARCHAR2 can be up to 32767 bytes. For SQL the limit is 4000 bytes

Can I increase the size of this variable without worrying about the SQL limit?

Answer

Andre Kirpitch picture Andre Kirpitch · Aug 11, 2014

See the official documentation (http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm#i54330)

Variable-length character string having maximum length size bytes or characters. Maximum size is 4000 bytes or characters, and minimum is 1 byte or 1 character. You must specify size for VARCHAR2. BYTE indicates that the column will have byte length semantics; CHAR indicates that the column will have character semantics.

But in Oracle Databast 12c maybe 32767 (http://docs.oracle.com/database/121/SQLRF/sql_elements001.htm#SQLRF30020)

Variable-length character string having maximum length size bytes or characters. You must specify size for VARCHAR2. Minimum size is 1 byte or 1 character. Maximum size is: 32767 bytes or characters if MAX_STRING_SIZE = EXTENDED 4000 bytes or characters if MAX_STRING_SIZE = STANDARD