What is the difference between varchar2 (10 byte) and varchar2 (10 char )?

Source: Internet
Author: User

The varchar2 datatype specifies a variable-length character string. when you create a varchar2 column, you supply the maximum number of bytes or characters of data that it can hold. oracle subsequently stores each value in the column exactly as you specify it, provided the value does not exceed the column's maximum length of the column. if you try to insert a value that exceeds the specified length, then oracle returns an error.

You must specify a maximum length for a varchar2 column. this maximum must be at least 1 byte, although the actual string stored is permitted to be a zero-length string (''). you can use the char qualifier, for example varchar2 (10 char), to give the maximum length in characters instead of bytes. A character is technically a code point of the database character set. char and byte qualifiers override the setting of the nls_length_semantics parameter, which has a default of bytes. for performance reasons, Oracle recommends that you use the nls_length_semantics parameter to set length semantics and that you use the byte and char qualifiers only when necessary to override the parameter. the maximum length of varchar2 data is 4000 bytes. oracle compares varchar2 values using nonpadded comparison semantics.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.