DataTypes in Oracle

本文详细介绍了Oracle数据库中各种数据类型的特性和使用方式,包括数值型、日期时间型、字符型、二进制型及大型对象类型等。每种数据类型都配以具体的定义和示例,帮助读者更好地理解和应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

资源下载链接为: https://pan.quark.cn/s/d9ef5828b597 在本文中,我们将探讨如何通过 Vue.js 实现一个带有动画效果的“回到顶部”功能。Vue.js 是一款用于构建用户界面的流行 JavaScript 框架,其组件化和响应式设计让实现这种交互功能变得十分便捷。 首先,我们来分析 HTML 代码。在这个示例中,存在一个 ID 为 back-to-top 的 div 元素,其中包含两个 span 标签,分别显示“回到”和“顶部”文字。该 div 元素绑定了 Vue.js 的 @click 事件处理器 backToTop,用于处理点击事件,同时还绑定了 v-show 指令来控制按钮的显示与隐藏。v-cloak 指令的作用是在 Vue 实例渲染完成之前隐藏该元素,避免出现闪烁现象。 CSS 部分(backTop.css)主要负责样式设计。它首先清除了一些默认的边距和填充,对 html 和 body 进行了全屏布局,并设置了相对定位。.back-to-top 类则定义了“回到顶部”按钮的样式,包括其位置、圆角、阴影、填充以及悬停时背景颜色的变化。此外,与 v-cloak 相关的 CSS 确保在 Vue 实例加载过程中隐藏该元素。每个 .page 类代表一个页面,每个页面的高度设置为 400px,用于模拟多页面的滚动效果。 接下来是 JavaScript 部分(backTop.js)。在这里,我们创建了一个 Vue 实例。实例的 el 属性指定 Vue 将挂载到的 DOM 元素(#back-to-top)。data 对象中包含三个属性:backTopShow 用于控制按钮的显示状态;backTopAllow 用于防止用户快速连续点击;backSeconds 定义了回到顶部所需的时间;showPx 则规定了滚动多少像素后显示“回到顶部”按钮。 在 V
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值