Summary of Oracle BASIC data Types "Oracle"

Source: Internet
Author: User

Oracle Basic data types (also called built-in data types built-in datatypes) can be categorized by type: String type, Number type, date type, LOB type, LONG raw& RAW type, ROWID & urowid type.

Before Apple told the string type, let's talk about encoding. Data of string types can be encoded into both the database character set (Char/varchar2/clob/long) and the international character set (NCHAR/NVARCHAR2/NCLOB). String data in a database is stored in a data block only after it is converted to a number by a character set (binary). With different encoding set conversions, even the same characters may be converted to different binary encodings. This is also the cause of garbled. The encoding format of a database is typically specified when the database is created. Of course, you can also modify the database encoding.

To view the data types that the database view contains:SELECT * from Dba_types WHERE the OWNER is NULL. details see oracle®database SQL Language Quick Refer ence 10/11G or official documents

A String type

The string data type can also be divided into fixed-length types (char/nchar) and variable-length types (VARCHAR2/NVARCHAR2) based on storage space.

Fixed length: means that although the input field value is less than the limit length of the field, the contents of the field value are stored in the data block when the data is actually stored and the space is automatically filled to the right. This approach is a waste of space, but storage efficiency is better than variable length types. It also reduces the migration of data rows to occur.

Variable length: means that when the input field value is less than the limit length of the field, the contents of the field value are stored directly in the data block without padding, which saves block space.

1.1:char type CHAR (size [BYTE | CHAR])

Char type, fixed-length string, is padded with spaces to reach its maximum length. A non-null char (12) always contains 12 bytes of information. The Char field can store up to 2,000 bytes of information. If you do not specify a char length when you create a table, the default is 1. In addition you can specify that it stores bytes or characters, such as char (Bytye) char (three char). In general, the default is to store bytes, you can view the database parameters

The value of the nls_length_semantics.

SQL Code
  1. SQL> show parameter nls_length_semantics;
  2. NAME TYPE VALUE
  3. ------------------   ----------- -----------------
  4. Nls_length_semantics string BYTE
  5. eg
  6. CREATE TABLE TEST
  7. (
  8. Name_old CHAR(Ten),
  9. Name_new Char(ten char)
  10. )
  11. INSERT into TEST
  12. ( name_old, name_new)
  13. SELECT ' Abcdefghij ' , ' you clear bytes with character ' from DUAL;
  14. COMMIT;
  15. INSERT into TEST
  16. ( name_old, name_new)
  17. SELECT ' You clear bytes with character ' , ' Abcdefghij ' from DUAL;
  18. ORA-12899: Column "SYS". " TEST "." Name_old "value is too large (actual value: 24, Maximum: 10)

Summary of Oracle BASIC data Types "Oracle"

Related Article

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.