Introduction to Oracle data types - posted

Introduction to Oracle data types

  I. Overview
  defined in the ORACLE8: scalar (SCALAR), the composite (the COMPOSITE), reference (the REFERENCE) and LOB four data types, their characteristics are detailed below.
  Second, the scalar (SCALAR)
  of the same type valid scalar type column of the database is used, in addition it has some extensions. It is divided into seven groups: numbers, characters, lines, date, line identification, Boolean and credible.
  Digital, there are three basic types which --NUMBER, PLS_INTEGER and BINARY_INTENER. NUMBER integer or a real number can be described, and description only PLS_INTEGER and BINARY_INTENER integer.
  NUMBER, is stored in decimal format, it is easy storage, but on the computing system will automatically convert it to perform binary operations. It is defined way NUMBER (P, S), P is the resolution, maximum 38, S is the scale range, the value at -84 ... 127. For example: NUMBER (5,2) may be used to store a value of 999.99 -999.99 .... P, S may be omitted in the definition, for example: NUMBER (5), NUMBER the like;
  BINARY_INTENER used herein to describe not stored in the database, but the need for a signed integer value calculated. It is expressed in 2's complement binary form. Often use this type of loop counter.
  PLS_INTEGER and BINARY_INTENER only difference is calculated at which an overflow occurs, BINARY_INTENER type variable will be automatically assigned to a type NUMBER without error, the variable type PLS_INTEGER error will occur.
  Characters, including CHAR, VARCHAR2 (VARCHAR), LONG , NCHAR and NVARCHAR2 types.
  CHAR, description string of fixed length, if the actual value of the length, the system will define the filling space is not enough. Its declaration is as follows CHAR (L), L is the string length defaults to 1, as a variable maximum 32767 characters, stored as data in the maximum ORACLE8 2000.
  VARCHAR2 (VARCHAR), described variable-length strings. Its declaration is as follows VARCHAR2 (L), L is the length of the string, there is no default, as a variable maximum 32,767 bytes, as the data stored in the maximum of 4000 ORACLE8. In the multi-byte locales, the number of characters actually stored values L may be less than, for example: when the Chinese language environment (SIMPLIFIED CHINESE_CHINA.ZHS16GBK), a VARCHAR2 (200) can be stored in the data columns 200 or 100 English characters characters characters.
  LONG, it can be used to store in the database up to 2G stored data, as a variable may represent a maximum of 32760 bytes of variable length strings.
  NCHAR, NVARCHAR2, national character set, closely related to the NLS environment variables specified set of languages, and to use CHAR, the same VARCHAR2.
  Row, and LONG RAW RAW including two types. For storing binary data, the conversion is not between the character sets.
  The RAW, similar to the CHAR, declaratively RAW (L), L is the length, in bytes, the maximum as a database column 2000, the maximum 32,767 bytes as the variable.
  LONG RAW, similar LONG, maximum storage as a database column 2G bytes of data, as a variable maximum 32,760 bytes.
  Date, only one type --date, for storing time information, a station 7 bytes (from the second century), absolutely no "Millennium Bug".
  Line identification, only one type --ROWID, used to store "row identifier" function can be used to identifying a row ROWIDTOCHAR converted into characters.
  Istanbul, only one type --BOOLEAN, can only represent TRUE, FALSE, or NULL.
  Credible, only one type --MLSLABEL, can be used to store variable length binary label the TRUSTED ORACLE. In the standard ORACLE, you can only store a NULL value.
  Third, the composite (the COMPOSITE)
  scalar types are predefined through the use of these types of compound types may be derived. There are records table.
  Recording, can be seen as a set of scalar composite structure, which statement as follows:
  the TYPE record_type_name the IS the RECORD
  (filed1 Type1 [the NOT NULL] [: = exprl]
  .......
  filedn typen [the NOT NULL] [: = exprn])
  wherein, record_type_name is the record type name. (Is not looking like CREATE TABLE? ......) related variables must be defined when referring to record only TYPE, not VARIABLE.
  Table, not the physical data storage, where a variable type, also called PL / SQL table, which is similar to the array in the C language, is also similar in approach. Its declaration is as follows:
  the TYPE table_type_name the IS. OF scalar_type the INDEX TABLE BY BINARY_INTENER;
  wherein, table_type_name is the type name, scalar_type scalar type is a type declaration. Also you must define the relevant variables reference. And an array of different tables, table with two columns, KEY and VALUE, KEY is BINARY_INTENER declaration defining, VALUE is declared scalar_type declaration.
  In addition to the records and tables, as well as the object type, the set of (nested tables and VARRAYS) type, etc., which will be specifically explained.
  Fourth, the reference (REFERENCE)
  before PL / SQL8.0, only one type --REF CURSOR, the cursor is. It is relatively simple definition,
  CURSOR cursor_name from the IS SELECT ..... .....;
  after PL / SQL8.0, introduced REF type, which points to an object. This type will be explained separately. (When I say understand, so in front of an expert ......)
  five, type LOB
  LOB variable is mainly used to store large amounts of data in a database field, the largest 4G bytes of content can be stored (so big, deposit VCD ?,waste!). There are:
  the CLOB: LONG and ORACLE7 in similar types, single-byte character data storage. (Oh not used to keep Chinese ...)
  NCLOB: for storing fixed-width multi-byte character data. (Example: Memory "Xiaoaojianghu" quite good)
  the BLOB: LONG RAW and the like, for storing unstructured binary data.
  BFILE: It is used to allow for large binary ORACLE database outer stored text read-only access.

 

Reproduced in: https: //my.oschina.net/cjkall/blog/195908

Guess you like

Origin blog.csdn.net/weixin_34191845/article/details/91756151