`
咖啡舞者
  • 浏览: 126883 次
  • 性别: Icon_minigender_1
  • 来自: 福州
社区版块
存档分类
最新评论

DataTypes in Oracle

阅读更多

The article below was written By Sanskruti

 


 

      A datatype is a classification of a particular type of information or data. Each value manipulated by Oracle has a datatype. The datatype of a value associates a fixed set of properties with the value. These properties cause Oracle to treat values of one datatype differently from values of another.

Numeric

The NUMBER data type is used to store zero, negative, positive, fixed, and floating point numbers with up to 38 digits of precision. Numbers range between 1.0x10 -130 and 1.0x10 126.

Numbers can be defined in following ways:

  • NUMBER(p,s)
    where p is the precision up to 38 digits and s is the scale (number of digits to the right of the decimal point). The scale can range between -84 to 127.
  • NUMBER (p)
    This is a fixed-point number with a scale of zero and a precision of p.
  • FLOAT[(p)]
    Oracle supports the ANSI data type FLOAT. Therefore, specifying a floating-point number you can use FLOAT data type instead of NUMBER data type.
    p is the binary precision that can range from 1 to 126. If p is not specified the default value is binary 126. To convert from binary to decimal precision, multiply p by 0.30103. To convert from decimal to binary precision, multiply the decimal precision by 3.32193. 126 digits of binary precision is roughly equivalent to 38 digits of decimal precision.
Date

Instead of storing date and time information in a character or numeric format, a separate data type was created. For each DATE data type, the following information is stored:
  • Century
  • Year
  • Month
  • Day
  • Hour
  • Minute
  • Second
You can easily retrieve the current date and time by using the function SYSDATE. Date arithmetic is possible using number constants or other dates. Only addition and subtraction are supported. For example, SYSDATE + 7 will return one week from today. Every database system has a default date format that is defined by the initialization parameter NLS_DATE_FORMAT. This parameter is usually set to DD-MON-YY, where DD is the day of the month (the first day of the month is 01), MON is the abbreviated month name, and YY is a two-digit year designation. If you do not specify a time, the default time is 12:00:00 a.m. If only the time component is captured, the default date will be the first day of the current month.
  • TIMESTAMP[(fractional_seconds_precision)]
The TIMESTAMP data type is an extension of the DATE data type. For each TIMESTAMP value, Oracle stores the following information: year, month, day, hour, minute, second and fraction of second. fractional_seconds_precision optionally specifies the number of digits in the fractional part of second and can be a number in the range 0 to 9. The default is 6. The TIMESTAMP data type is available in Oracle 9i Release 1 (9.0.1) or later.

Character
  1. The CHAR data type is used where fixed-length fields are necessary. Any length up to 255 characters can be specified. The default length is 1. When data is entered, any space left over will be filled with blanks. All alpha-numeric characters are allowed.
  2. The VARCHAR2 is used for variable-length fields. A length component must be supplied when you use this data type. The maximum length is 2000 characters. All alpha-numeric characters are allowed.
  3. The LONG data type is used to store large amounts of variable-length text. Any length up to 2 GB can be specified. Be aware that there are some restrictions to using this data type, such as:
    • Only one column per table can be defined as LONG.
    • A LONG column cannot be indexed.
    • A LONG column cannot be passed as an argument to a procedure.
    • A function cannot be used to return a LONG column.
    • A LONG column cannot be used in where, order by, group by, or connect by clauses.
  4. NCHAR[(n)]
    Fixed-length character data of length n characters or bytes, depending on the national character set. The maximum length is determined by the number of bytes required to store each character, with an upper limit of 2000 bytes. The default value is 1.
  5. NVARCHAR2(n)
    Variable-length character data having maximum length n characters or bytes, depending on the national character set. The maximum length is determined by the number of bytes required to store each character, with an upper limit of 4000 bytes. You must specify the maximum length for NVARCHAR2 columns.
Binary

Two data types, RAW and LONGRAW, are available for storing binary type data such as digitized sound and images. These data types take on similar characteristics as the VARCHAR2 and LONG data types already mentioned. Use the RAW data type to store binary data up to 2000 characters and use the LONGRAW data type to store binary data up to 2 GB. Oracle only stores and retrieves binary data; no string manipulations are allowed. Data is retrieved as hexadecimal character values.

Others

BLOB, CLOB, NCLOB and BFILE

The built-in LOB data types BLOB, CLOB and NCLOB (stored internally), and BFILE (stored externally), can store large and unstructured data such as text, images and spatial data up to 4 gigabytes in size.

BLOB
The BLOB data type stores binary large objects. BLOB can store up to 4 gigabytes of binary data.

CLOB

The CBLOB data type stores character large objects. CLOB can store up to 4 gigabytes of character data.

NCLOB

The NCBLOB data type stores character large objects in multibyte national character set. NCLOB can store up to 4 gigabytes of character data.


BFILE

The BFILE data type enables access to binary file LOBs that are stored in file systems outside the Oracle database. A BFILE column stores a locator, which serves as a pointer to a binary file on the server's file system. The maximum file size supported is 4 gigabytes.


ROWID and UROWID

ROWID

The ROWID data type is used to store physical address of each row in the database. This data type is primarily for values returned by the ROWID pseudocolumn.


UROWID[(n)]

The UROWID data type is used to store the logical addresses of index-organized and foreign tables.
n is the size of a UROWID column. The range of n is 1 to 4000. The default value is 4000.
This data type is available in Oracle 9i Release 1 (9.0.1) or later.

<!----><!---->

评论

相关推荐

    Infinity Science – Software Engineering and Testing.pdf

    19.4 Data Types in Oracle 335 19.5 Syntax and Query in Oracle 336 19.6 Functions 344 19.7 Primary Keys 345 19.8 Data Export 346 19.9 Data Import 347 Chapter 20. SQL Server 2000 349 ...

    [Oracle] Oracle Spatial 应用扩展 (英文版)

    Get to grips with how to use Oracle Spatial's standards compliant geometry data types to develop cross-vendor database solutions to common problems ☆ 出版信息:☆ [作者信息] Simon Greener , Siva ...

    Oracle Anydata 自定义对象UDT示例

    http://www.toadworld.com/platforms/oracle/w/wiki/2004.datatypes-processing-an-anydata-value STATIC FUNCTION ConvertObject(obj IN "&lt;ADT_1&gt;") return AnyData, STATIC FUNCTION ConvertObject(obj IN ...

    Oracle To Postgres

    applications and use JDBC, the “Data types and JDBC” section will be particularly useful. Oracle and PostgreSQL both conform to standard SQL. However, they contain several extensions and ...

    oracle advanced sql 高级SQL教程 ORACLE官方教材

    Using a Subquery in the FROM Clause 4-10 Scalar Subquery Expressions 4-11 Scalar Subqueries: Examples 4-12 Correlated Subqueries 4-14 Using Correlated Subqueries 4-16 Using the EXISTS Operator 4-18 ...

    Expert Oracle Database Architecture 2nd 原版PDF by Kyte

    The inspiration for the material contained in this book comes from my experiences ...structures in the database such as tables, indexes, and datatypes, covering techniques for making optimal use of them.

    Oracle PL/SQL programming(5th Edition)

    Explore datatypes, conditional and sequential control statements, loops, exception handling, security features, globalization and localization issues, and the PL/SQL architecture Understand and use ...

    Oracle Security

    Security in an oracle System Chapter 1 Oracle and Security What’s It All About? The Oracle Security Model Procedures, Policies, and Plans If I Had a Hammer... Chapter 2 Oracle System Files ...

    Beginning Oracle SQL

    Get a handle on Oracle Database’s support for object types in the database Who is this book for? This book is aimed at developers and database administrators who must write SQL statements to execute...

    Expert Oracle GoldenGate.pdf

    The authors share their experience in the form of tutorials on designing and implementing all types of Oracle GoldenGate environments. You'll learn methods for tuning Oracle GoldenGate performance. ...

    oracle-pl-sql-programming-5th-edition

    Explore datatypes, conditional and sequential control statements, loops, exception handling, security features, globalization and localization issues, and the PL/SQL architecture Understand and use ...

    unidac74.12d26-pro.rar for delphi 10.3.1

    only dataset" error in Android is fixed MySQL data provider Bug with setting the data type of the parameter to BOOLEAN for all TINYINT system data types in the functions is fixed PostgreSQL data ...

    Oracle帮助chm手册

    1 Introduction and Upgrading 2 OCI Programming Basics 3 Datatypes 4 Using SQL Statements in OCI 5 Binding and Defining

    SQL袖珍参考手册(第3版)

    DB2 syntax and datatypes, some compatible with Oracle MySQL features such as the TIMESTAMP type and the TO_SECONDS function 目录: Introduction Analytic Functions CASE Expressions: Simple ...

    Expert.Oracle.Indexing.and.Access.Paths.2nd.epub

    Let Expert Indexing in Oracle Database 12c be your guide to deep mastery of the most fundamental performance optimization structure in Oracle Database. Explains how indexes help performance, and ...

    Oracle PL/SQL Programming, 5th Edition

    Explore datatypes, conditional and sequential control statements, loops, exception handling, security features, globalization and localization issues, and the PL/SQL architecture Understand and use ...

    Expert.Oracle.Indexing.and.Access.Paths

    Let Expert Indexing in Oracle Database 12c be your guide to deep mastery of the most fundamental performance optimization structure in Oracle Database. Explains how indexes help performance, and ...

    Devart_UniDAC_7.4.12_Professional_D7-D10.3_Rio_Full_Source_Code

    Bug with setting the data type of the parameter to BOOLEAN for all TINYINT system data types in the functions is fixed PostgreSQL data provider Bug with reading and writing of the floating point ...

    最完整的Toad For Oracle使用手册

    Types 1004 Users 1010 Views 1012 Troubleshooting 1017 Unicode Troubleshooting 1017 Hints and Tips: Connecting To Personal Oracle 1018 Hints and Tips: Table Does Not Exist Errors 1019 Create Support ...

    Oracle Database 12c PL-SQL programming

    Filled with detailed examples and expert strategies from an Oracle ACE, Oracle Database 12c PL/SQL Programming explains how to retrieve and process data, write PL/SQL statements, execute effective ...

Global site tag (gtag.js) - Google Analytics