Why shouldn't I make all my PL/SQL-only VARCHAR2 32767 bytes?

前端 未结 3 1976
天命终不由人
天命终不由人 2020-12-30 09:47

Or should I ?

(The title is inspired by Gary Myers\' comment in Why does Oracle varchar2 have a mandatory size as a definition parameter?)

Consider the follo

3条回答
  •  情深已故
    2020-12-30 10:40

    Maybe it's because I came of age in the era when the most memory any system had was 48k and then, happy days, up to a full 64k. And it was not virtual, what you allocated is what you got (wyaiwyg) (WAY-WIG?). I see in a lot of younger programmers a tendency to be lazy in their design and hide design flaws by throwing more memory at it.

    If we get into the habit of just typing varchar2(MAX) whenever we define a string variable, we stop thinking about the length. But sometimes length matters. If we haven't already done so, as soon as we type the ( then we should stop and put some thought into how big it really needs to be. Does the size matter here? If so, what is a reasonable maximum (or minimum)? This forces us to look beyond the bytes and fields and indexes to the actual "thing" we are trying to work with. That is never a bad idea.

    Discipline is hard. We should be developing habits to enforce it whenever we can. Good data and code design is difficult by nature. There are tools and techniques we can use to make it a little easier, but we shouldn't be doing anything just because it is easier. That's the path to the Dark Side and it catches up to us sooner or later.

提交回复
热议问题