开发者

VARCHAR(MAX) versus VARCHAR(n) in Oracle

Similar question, but for Oracle.

Why would I not always want to choose V开发者_StackOverflow中文版ARCHAR(MAX)?


Because it doesn't work in Oracle! You could declare all columns as VARCHAR2(4000) if you wanted, but it isn't recommended by any means. There will be no difference in storage or performance of the database, but:

  • you lose a constraint on the sensible values that can be stored in the column
  • some client applications will allocate 4000 bytes of memory to receive data from the column when (say) 10 is all it will ever contain.


Probably because Oracle does not support VARCHAR(MAX).

VARCHAR should not be used in Oracle at all.

As for now, it's a synonym for VARCHAR2, but it may change in future so that it will distinguish between an empty string and a NULL.

VARCHAR is supposed to do it but doesn't in current versions of Oracle, and hence should not be used.

In Oracle, maximum length for a VARCHAR2 is 4000 in SQL and 32767 in PL/SQL.

For larger values, you should use CLOB, but it's very different from a VARCHAR2. You should use special methods to access it, etc.


For starters, Oracle doesn't have a VARCHAR(MAX) datatype

Reference:

  • Oracle datattypes
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜