当前位置:Gxlcms > 数据库问题 > Oracle Schema Objects——Tables——Oracle Data Types

Oracle Schema Objects——Tables——Oracle Data Types

时间:2021-07-01 10:21:17 帮助过:23人阅读

字符数据类型

      • Character data types store character (alphanumeric) data in strings.

字符数据类型存储在字符串中的字符 (字母或数字) 数据

 

      • The most commonly used character data type is VARCHAR2, which is the most efficient option for storing character data.

最常用的字符数据类型是 VARCHAR2,它是用于存储字符数据的最有效的选项

 

      • The byte values correspond to the character encoding scheme, generally called a character set or code page. The database character set is established at database creation.

与字符编码模式相对应的字节值,一般称为 字符集代码页。 数据库字符集是在数据库创建时建立的。

 

      •  Examples of character sets are 7-bit ASCII, EBCDIC, and Unicode UTF-8.

字符集的例子有 7 ASCII 码、 EBCDIC码、和 Unicode utf-8

 

      • The length semantics of character data types can be measured in bytes or characters.

字符数据类型的长度语义可以以字节或字符为单位。

 

      •  Byte semantics treat strings as a sequence of bytes. This is the default for character data types.

字节语义将字符串视为一个字节序列。 这是字符数据类型的默认值。

 

      • Character semantics treat strings as a sequence of characters. A character is technically a code point of the database character set.

字符语义将字符串视为字符序列。 一个字符在技术上是数据库字符集的编码点。

 

VARCHAR2 CHAR NCHARNVARCHAR2

 

Oracle Database compares VARCHAR2 values using nonpadded comparison semantics and compares CHAR values using blank-padded comparison semantics.

Oracle 数据库将使用非填充比较语义来比较 VARCHAR2 值,而使用空白填充比较语义来比较 CHAR 值。

VARCHAR2  

CHAR

The VARCHAR2 data type stores variable-length character literals.

VARCHAR2 数据类型存储变长字符文本

The terms literal and constant value are synonymous and refer to a fixed data value.

文本常量值这两个术语是同义词,指的是一个固定的数据值

CHAR stores fixed-length character strings.

CHAR 存储固定长度的字符串

 VARCHAR2(25):表示该列中存储的名字最多可以长达25个字节

      • When you create a table with a CHAR column, the column requires a string length. The default is 1 byte.

当创建一个有CHAR 列的表时,需要为该列指定一个字符串长度。默认值是 1 个字节。

      • The database uses blanks to pad the value to the specified length.

据库使用空格填充到指定的长度的值

NVARCHAR2  

NCHAR

NVARCHAR2 NCHAR 数据类型存储 Unicode 字符数据

Unicode 是一种通用的编码字符集,可以将任何语言的信息存储在一种字符集中。

当您创建数据库时,指定国家字符集。

NCHAR NVARCHAR2 数据类型的字符集必须是 AL16UTF16 UTF8

这两种字符集都使用 Unicode 码。

当您创建一个有 NCHAR NVARCHAR2 列的表时,其最大大小始终是字符长度语义。

对于 NCHAR NVARCHAR2,字符长度语义是默认的,也是唯一的长度语义。

The NCHAR and NVARCHAR2 data types store Unicode character data.

Unicode is a universal encoded character set that can store information in any language using a single character set.

NCHAR stores fixed-length character strings that correspond to the national character set, whereas NVARCHAR2 stores variable length character strings.

You specify a national character set when creating a database.

The character set of NCHAR and NVARCHAR2 data types must be either AL16UTF16 or UTF8.

Both character sets use Unicode encoding.

When you create a table with an NCHAR or NVARCHAR2 column, the maximum size is always in character length semantics.

Character length semantics is the default and only length semantics for NCHAR or NVARCHAR2.

NVARCHAR2 存储可变长度的字符串

NCHAR存储对应于国家字符集的固定长度字符串

 

Numeric Data Types

数字数据类型

      • The Oracle Database numeric data types store fixed and floating-point numbers, zero, and infinity.

Oracle 数据库的数字数据类型存储固定和浮点数字、零、或无穷

      • Some numeric types also store values that are the undefined result of an operation, which is known as "not a number" or NAN.

某些数值类型也可以存储未定义操作的结果值,叫做"非数字" NAN

 

      • Oracle Database stores numeric data in variable-length format. Each value is stored in scientific notation, with 1 byte used to store the exponent.

Oracle 数据库以变长格式存储数字数据。用科学计数法存储值,其中一个字节用于存储指数

      • The database uses up to 20 bytes to store the mantissa, which is the part of a floating-point number that contains its significant digits.

数据库使用最多 20 个字节存储尾数,即浮点数的有效位数部分。

      • Oracle Database does not store leading and trailing zeros.

Oracle 数据库不会存储前导零和结尾零

 

NUMBER Data Type

 

      • The NUMBER data type stores fixed and floating-point numbers.

NUMBER 数据类型存储固定和浮点数字

      • The database can store numbers of virtually any magnitude.

数据库可以存储几乎任何规模的数字。

      • This data is guaranteed to be portable among different operating systems running Oracle Database.

此数据保证在运行 Oracle 数据库的不同操作系统之间可移植。

      • The NUMBER data type is recommended for most cases in which you must store numeric data.

大多数情况下,当您必须存储数值数据时,推荐使用 NUMBER 数据类型。

      • You specify a fixed-point number in the form NUMBER(p,s), where p and s refer to the following characteristics:

NUMBER(p,s)的形式定义定点数,p s 有以下特征:

精度

Precision

he precision specifies the total number of digits.

精度指定数字的总长度

If a precision is not specified, then the column stores the values exactly as provided by the application without any rounding.

如果不指定精度,则列按应用程序提供的数据存储值,不作任何舍入。

小数位数

Scale

The scale specifies the number of digits from the decimal point to the least significant digit.

小数位数指从十进制的小数点到最小有效数字的位数。

Positive scale counts digits to the right of the decimal point up to and including the least significant digit.

正小数位数从小数点向右计数直至最小有效位。

Negative scale counts digits to the left of the decimal point up to but not including the least significant digit.

负小数位数从小数点向左计数直至(但不包括)最小有效数字。

 If you specify a precision without a scale, as in NUMBER(6), then the scale is 0.

如果您指定了精度但没有指定小数位数,如 NUMBER(6),那么小数位数为 0

 

Floating-Point Numbers

      • Oracle Database provides two numeric data types exclusively for floating-point numbers: BINARY_FLOAT and BINARY_DOUBLE.

Oracle 数据库为浮点数提供了两种互斥的数值数据类型: BINARY_FLOAT BINARY_DOUBLE

      • These types support all of the basic functionality provided by the NUMBER data type.

这两种类型支持所有 NUMBER 数据类型提供的基本功能

      • However, while NUMBER uses decimal precision, BINARY_FLOAT and BINARY_DOUBLE use binary precision, which enables faster arithmetic calculations and usually reduces storage requirements.

然而,相比 NUMBER使用十进制精度BINARY_FLOAT BINARY_DOUBLE 使用二进制精度,可以使算术计算更快并且通常可以降低存储需求

 

      • BINARY_FLOAT and BINARY_DOUBLE are approximate numeric data types.

BINARY_FLOAT BINARY_DOUBLE 是近似数字数据类型

      • They store approximate representations of decimal values, rather than exact representations.

它们存储十进制的值的近似表示,而不是精确的表示形式

 

      •  For example, the value 0.1 cannot be exactly represented by either BINARY_DOUBLE or BINARY_FLOAT.

例如值 0.1不能用BINARY_DOUBLE BINARY_FLOAT 完全精确地表示。他们经常用于科学计算。

      • They are frequently used for scientific computations. Their behavior is similar to the data types FLOAT and DOUBLE in Java and XMLSchema.

其行为类似于 Java XMLSchema 中的 FLOAT DOUBLE 数据类型。

Datetime Data Types

日期时间数据类型

Datetime Data Types

 

The datetime data types are DATE and TIMESTAMP. Oracle Database provides comprehensive time zone support for time stamps.

日期时间数据类型包括 DATE TIMESTAMPOracle 数据库为时间戳提供全面的时区支持。

DATE Data Type

The DATE data type stores date and time. Although datetimes can be represented in character or number data types, DATE has special associated properties.

DATE 数据类型存储日期和时间。尽管日期时间可以用字符或数字数据类型表示,DATE 具有特殊的相关属性。

 

The database stores dates internally as numbers. Dates are stored in fixed-length fields of 7 bytes each, corresponding to century, year, month, day, hour, minute, and second.

数据库在内部将日期存储为数字。日期被存储为固定长度的域, 7 个字,分别对应世纪、 年、 月、 日、 小时、分、和秒

 

Note:

 

  • The database displays dates according to the specified format model.

数据库根据指定的 格式模型显示日期。

  • A format model is a character literal that describes the format of a datetime in a character string. The standard date format is DD-MON-RR, which displays dates in the form 01-JAN-09.

格式模型是一个描述在字符串中的日期时间格式的字符文字。标准的日期格式是 DD-MON-RR,它会以 01-JAN-09 的形式显示日期。

 

  • RR is similar to YY (the last two digits of the year), but the century of the return value varies according to the specified two-digit year and the last two digits of the current year.

RR类似于 YY (年的最后两位),但返回值的世纪值会因指定的两位年份及本年度的最后两位不同而不同

  • Assume that in 1999 the database displays 01-JAN-09. If the date format uses RR, then 09 specifies 2009, whereas if the format uses YY, then 09 specifies 1909. You can change the default date format at both the instance and the session level.

假设在 1999 年,数据库显示为 01-JAN-09。如果日期格式使用 RR,那么 09 指的是 2009,而如果格式使用 YY,那 09 指的是 1909。您可以更改实例或会话级别的默认日期格式

  • Oracle Database stores time in 24-hour formatHH:MI:SS. If no time portion is entered, then by default the time in a date field is 00:00:00 A.M. In a time-only entry, the date portion defaults to the first day of the current month.

Oracle 数据库以 24 小时制格式存储时间 — — HH:MI:SS。如果不输入的任何时间部分,那么默认情况下,日期字段中的时间是凌晨 00: 00: 00,如果只输入了时间,则日期部分默认为当月的第一天。

TIMESTAMP Data Type

      • The TIMESTAMP data type is an extension of the DATE data type.

TIMESTAMP 数据类型是日期数据类型的扩展

      • It stores fractional seconds in addition to the information stored in the DATE data type.

除了存储在 DATE 数据类型的信息,它同时还存储秒的小数部分

      • The TIMESTAMP data type is useful for storing precise time values, such as in applications that must track event order.

TIMESTAMP 数据类型对于存储精确时间的值很有用,比如那些必须跟踪事件顺序的应用程序。

      • The DATETIME data types TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE are time-zone aware.

DATETIME 数据类型 TIMESTAMP WITH TIME ZONE TIMESTAMP WITH LOCAL TIME ZONE 能感知时区。

      • When a user selects the data, the value is adjusted to the time zone of the user session. This data type is useful for collecting and evaluating date information across geographic regions.

人气教程排行