暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Why should I use varchar2 instead of char types ?

2011-01-01
520

The Oracle (tm) Users' Co-Operative FAQ

Why should I use varchar2 instead of char types ?


Author's name: Martin Haltmayer

Author's Email: Martin.Haltmayer@0800-einwahl.de

Date written: 14 June 2001

Oracle version(s): 8.1.7

Are there any reasons why the varchar2() data type is generally more appropriate than the char() data type for character data ?


Several reasons for using varchar2 instead of char:

1. char (xx) will always rpad data with blanks. This is a guarantee for surprises when comparing data and using indexes for searches because implicit conversion strikes. Please look up the rules for implicit conversions.

2. A value of char will always consume full space in the database because it is padded. Therefore, indexes grow bigger and searches are slower.

3. As opposed to a wide-spread misunderstanding, char (1) does *not* use less space in the database than varchar2 (1) when the value 'a' is stored because also char (1) has a length field. This can be proved by the dump () function.  


Further reading: N/A



最后修改时间:2020-04-16 15:12:36
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论