- 浏览: 70770 次
- 性别:
- 来自: 杭州
文章分类
最新评论
2.2 Data Types
This chapter provides detailed descriptions of the differences in data types used by Microsoft SQL Server and Oracle databases. Specifically, this chapter contains the following information:
-
A table showing the base Microsoft SQL Server data types available and how they are mapped to Oracle data types
-
Recommendations based on the information listed in the table
2.2.1 Data Types Table
Table 2-2 Data Types in Oracle and Microsoft SQL Server
INTEGER |
Four-byte integer, 31 bits, and a sign. May be abbreviated as "INT" (this abbreviation was required prior to version 5). |
NUMBER(10) |
It is possible to place a table constraint on columns of this type (as an option) to force values between -2^31 and2^31. Or, place appropriate constraints such as: STATE_NO between 1 and 50 |
SMALLINT |
Two-byte integer, 15 bits, and a sign. |
NUMBER(6) |
It is possible to place a table constraint on columns of this type (optionally) to force values between -2^15 and 2^15. Or, place appropriate constraints such as: STATE_NO between 1 and 50 |
TINYINT |
One byte integer, 8 bits and no sign. Holds whole numbers between 0 and 255. |
NUMBER(3) |
You may add a check constraint of (x between 0 and 255) where x is column name. |
REAL |
Floating point number. Storage is four bytes and has a binary precision of 24 bits, a 7-digit precision. Data can range from –3.40E+38 to 3.40E+38. |
FLOAT |
The ANSI data type conversion to Oracle for REAL is FLOAT(63). By default, the Oracle Migration Workbench maps REAL to FLOAT(24) that stores up to 8 significant decimal digits in Oracle. The Oracle NUMBER data type is used to store both fixed and floating-point numbers in a format that is compatible with decimal arithmetic. You may want to add a check constraint to constrain range of values. Also, you get different answers when performing operations on this data type as the Oracle NUMBER type is more precise and portable than REAL. Floating-point numbers can be specified in Oracle in the following format: FLOAT[(b)]. Where [(b)] is the binary precision b and can range from 1 to 126. [(b)] defaults to 126. To check what a particular binary precision is in terms of decimal precision, multiply [(b)] by 0.30103 and round up to the next whole number. |
A floating point number. This column has 15-digit precision. |
FLOAT |
The ANSI data type conversion to Oracle for FLOAT(p) is FLOAT(p). The ANSI data type conversion to Oracle for DOUBLE PRECISION is FLOAT(126). By default, the Oracle Migration Workbench maps FLOAT to FLOAT(53), that stores up to 16 significant decimal digits in Oracle. The Oracle NUMBER data type is used to store both fixed and floating-point numbers in a format compatible with decimal arithmetic.You get different answers when performing operations on this type due to the fact that the Oracle NUMBER type is much more precise and portable than FLOAT, but it does not have the same range. The NUMBER data type data can range from -9.99.99E+125 to 9.99.99E+125 (38 nines followed by 88 zeros). NOTE: If you try to migrate floating point data greater than or equal to 1.0E+126 then Migration Workbench will fail to insert this data in the Oracle database and1 will return an error.This also applies to negative values less than or equal to -1.0E+126. |
|
Floating-point numbers can be specified in Oracle using FLOAT[(b)], where [(b)] is the binary precision [(b)] and can range from 1 to 126. [(b)] defaults to 126.To check what a particular binary precision is in terms of decimal precision multiply [(b)] by 0.30103 and round up to the next whole number. If they are outside of the range, large floating-point numbers will overflow, and small floating-point numbers will underflow. |
|||
BIT |
A Boolean 0 or 1 stored as one bit of a byte. Up to 8-bit columns from a table may be stored in a single byte, even if not contiguous. Bit data cannot be NULL, except for Microsoft SQL Server 7.0, where null is allowed by the BIT data type. |
NUMBER(1) |
In Oracle, a bit is stored in a number(1) (or char). In Oracle, it is possible to store bits in a char or varchar field (packed) and supply PL/SQL functions to set / unset / retrieve / query on them. |
Fixed-length string of exactly n 8-bit characters, blank padded. Synonym for CHARACTER. 0 < n < 256 for Microsoft SQL Server. 0 < n < 8000 for Microsoft SQL Server 7.0. |
CHAR(n) |
Pro*C client programs must use mode=ansi to have characters interpreted correctly for string comparison, mode=oracle otherwise. A CHAR data type with a range of 2001 to 4000 is invalid. SQL Developer automatically converts a CHAR datatype with this range to VARCHAR2. |
|
Varying-length character string. 0 < n < 256 for Microsoft SQL Server. 0 < n < 8000 for Microsoft SQL Server 7.0. |
VARCHAR2(n) |
||
TEXT |
Character string of 8-bit bytes allocated in increments of 2k pages. "TEXT" is stored as a linked-list of 2024-byte pages, blank padded. TEXT columns can hold up to (231-1) characters. |
CLOB |
The CLOB field can hold up to 4GB. |
IMAGE |
Binary string of 8-bit bytes. Holds up to (231-1) bytes of binary data. |
BLOB |
The BLOB field can hold up to 4GB. |
BINARY(n) |
Fixed length binary string of exactly n 8-bit bytes. 0 < n < 256 for Microsoft SQL Server. 0 < n < 8000 for Microsoft SQL Server 7.0. |
RAW(n)/BLOB |
|
VARBINARY(n) |
Varying length binary string of up to n 8-bit bytes. 0 < n < 256 for Microsoft SQL Server. 0 < n < 8000 for Microsoft SQL Server 7.0. |
RAW(n)/BLOB |
|
Date and time are stored as two 4-byte integers. The date portion is represented as a count of the number of days offset from a baseline date (1/1/1900) and is stored in the first integer. Permitted values are legal dates between 1st January, 1753 AD and 31st December, 9999 AD. Permitted values in the time portion are legal times in the range 0 to 25920000. Accuracy is to the nearest 3.33 milliseconds with rounding downward. Columns of type DATETIME have a default value of 1/1/1900. |
DATE |
The precision of DATE in Oracle and DATETIME in Microsoft SQL Server is different. The DATETIME data type has higher precision than the DATE data type. This may have some implications if the DATETIME column is supposed to be UNIQUE. In Microsoft SQL Server, the column of type DATETIME can contain UNIQUE values because the DATETIME precision in Microsoft SQL Server is to the hundredth of a second. In Oracle, however, these values may not be UNIQUE as the date precision is to the second. You can replace a DATETIME column with two columns, one with data type DATE and another with a sequence, in order to get the UNIQUE combination. It is preferable to store hundredths of seconds in the second column. The Oracle TIMESTAMP data type can also be used. It has a precision of 1/10000000th of a second. |
|
SMALL-DATETIME |
Date and time stored as two 2-byte integers. Date ranges from 1/1/1900 to 6/6/2079. Time is the count of the number of minutes since midnight. |
DATE |
With optional check constraint to validate the smaller range. |
MONEY |
A monetary value represented as an integer portion and a decimal fraction, and stored as two 4-byte integers. Accuracy is to the nearest 1/10,000. When inputting Data of this type it should be preceded by a dollar sign ($). In the absence of the "$" sign, Microsoft SQL Server creates the value as a float. Monetary data values can range from -922,337,203,685,477.5808 to 922,337,203,685,477.5807, with accuracy to a ten-thousandth of a monetary unit. Storage size is 8 bytes. |
NUMBER(19,4) |
Microsoft SQL Server inputs MONEY data types as a numeric data type with a preceding dollar sign ($) as in the following example, select * from table_x where y > $5.00 You must remove the "$" sign from queries. Oracle is more general and works in international environments where the use of the "$" sign cannot be assumed. Support for other currency symbols and ISO standards through NLS is available in Oracle. |
NCHAR(n) |
Fixed-length character data type which uses the UNICODE UCS-2 character set. n must be a value in the range 1 to 4000. SQL Server storage size is two times n. Note: Microsoft SQL Server storage size is two times n. The Oracle Migration Workbench maps columns sizes using byte semantics, and the size of Microsoft SQL Server NCHAR data types appear in the Oracle Migration Workbench Source Model with "Size" specifying the number of bytes, as opposed to the number of Unicode characters. Thus, a SQL Server column NCHAR(1000) will appear in the Source Model as NCHAR(2000). |
CHAR(n*2) |
|
NVARCHAR(n) |
Fixed-length character data type which uses the UNICODE UCS-2 character set. n must be a value in the range 1 to 4000. SQL Server storage size is two times n. Note: Microsoft SQL Server storage size is two times n. The Oracle Migration Workbench maps columns sizes using byte semantics, and the size of Microsoft SQL Server NVARCHAR data types appear in the Oracle Migration Workbench Source Model with "Size" specifying the number of bytes, as opposed to the number of Unicode characters. Thus, a SQL Server column NVARCHAR(1000) will appear in the Source Model as NVARCHAR(2000). |
VARCHAR(n*2) |
|
SMALLMONEY |
Same as MONEY except monetary data values from -214,748.3648 to +214,748.3647, with accuracy to one ten-thousandth of a monetary unit. Storage size is 4 bytes. |
NUMBER(10,4) |
Since the range is -214,748.3648 to 214,748.364, NUMBER(10,4) suffices for this field. |
TIMESTAMP is defined as VARBINARY(8) with NULL allowed. Every time a row containing a TIMESTAMP column is updated or inserted, the TIMESTAMP column is automatically increment by the system. A TIMESTAMP column may not be updated by users. |
NUMBER |
You must place triggers on columns of this type to maintain them. In Oracle you can have multiple triggers of the same type without having to integrate them all into one big trigger. You may want to supply triggers to prevent updates of this column to enforce full compatibility. |
|
VARCHAR(30) in Microsoft SQL Server. NVARCHAR(128) in Microsoft SQL Server 7.0. |
VARCHAR2(30) and VARCHAR2(128) respectively. |
TEXT and IMAGE data types in Microsoft SQL Server follow these rules:
-
The column of these data types cannot be indexed.
-
The column cannot be a primary key.
-
The column cannot be used in the GROUP BY, ORDER BY, HAVING, and DISTINCT clauses.
-
IMAGE and TEXT data types can be referred to in the WHERE clause with the LIKE construct.
-
IMAGE and TEXT data types can also be used with the SUBSTR and LENGTH functions.
In Microsoft SQL Server, only columns with variable-length data types can store NULL values. When you create a column that allows NULLs with a fixed-length data type, the column is automatically converted to a system variable-length data type, as illustrated in Table 2-3. These variable-length data types are reserved system data types, and users cannot use them to create columns
Table 2-3 Data Type Conversion for NULL Values
CHAR |
VARCHAR |
NCHAR |
NVARCHAR |
BINARY |
VARBINARY |
DATETIME, SMALLDATETIME |
DATETIMN |
FLOAT |
FLOATN |
INT, SMALLINT, TINYINT |
INTN |
DECIMAL |
DECIMALN |
NUMERIC |
NUMERICN |
MONEY, SMALLMONEY |
MONEYN |
Note:
The Oracle Migration Workbench Source Model will display table system data types for each column.Recommendations
In addition to the data types listed in Table 2-2, users can define their own data types in Microsoft SQL Server databases. These user-defined data types translate to the base data types that are provided by the server. They do not allow users to store additional types of data, but can be useful in implementing standard data types for an entire application.
You can map data types from Microsoft SQL Server to Oracle with the equivalent data types listed in Table 2-3. SQL Developer converts user-defined data types to their base type. You can defined how the base type is mapped to an Oracle type in the Data Type Mappings page in the Options dialog.
发表评论
-
关于Oracle 版本
2015-10-10 10:23 0第一部分是“Version Number",也就是产 ... -
了解Oracle数据库的版本号
2015-10-10 10:20 0Major Database Release ... -
PDF 资料
2013-03-13 15:45 0Java design pattern --Bob ... -
Oracle sys和system用户、sysdba 和sysoper系统权限、sysdba和dba角色的区别 [转]
2013-03-12 14:17 1025sys和system用户区别 1)最重要的区别,存储的数 ... -
Oracle 用户、对象权限、系统权限 [转]
2013-03-12 14:12 0--============================ ... -
表分区分割脚本
2013-03-12 13:10 738表分区分割脚本 -
Oracle Session 视图[转]
2013-03-06 10:17 977v$session v$session_wait v$ ... -
10G中查看历史执行计划信息[转]
2013-03-01 11:02 3764现在总结下10G的,使用的是AWR报告中的信息,主要是查询 ... -
Oracle 表连接 [转]
2013-02-26 15:20 649Oracle 表之间的连接分为三种: 1. 内连接(自然 ... -
oracle的number类型精度、刻度范围 [转]
2013-02-26 15:06 5254一、 oracle 的 number 类型精度、刻度范围 ... -
Oracle Tablespace
2012-11-29 16:53 01. 几个重要的TableSpace SYSTE ... -
[转]Optimizing SPLIT PARTITION and SPLIT SUBPARTITION Operations
2012-11-27 15:11 913Optimizing SPLIT PARTITION and ... -
Oracle splitting partitions简单小结[转]
2012-11-27 15:12 997http://www.oracleonlinux.cn/201 ... -
When the explanation doesn't sound quite right
2012-10-30 13:05 0When the explanatio ... -
oracle中join的用法 .
2012-10-10 11:43 0oracle中join的用法8i: create ... -
[转]Oracle中Left Outer Join和外关联(+)的区别
2012-11-27 15:15 844外关联是Oracle数据库的专有语句 Left Outer ... -
[转]关于ORACLE的锁表与解锁总结
2012-09-29 11:11 0总结1:Oracle的锁表与解锁 selects.userna ... -
not in/not exists 的 null 陷阱
2012-09-27 11:07 0[转]not in/not exists 的 nul ... -
Oracle Database Link Tutorials,Examples to create, use, manage and drop them[转]
2012-09-21 10:54 0Oracle Database Link TutorialsE ... -
Understanding Oracle QUERY PLAN
2012-01-06 11:28 1164Understanding Oracle QUERY PLAN ...
相关推荐
这需要配置正确的连接字符串,并使用适当的Oracle(如ODP.NET)或SQL Server(如System.Data.SqlClient)提供者。 2. 数据库元数据获取:通过执行SQL查询或使用特定的数据库API来获取表结构、列信息、主键和外键...
<type-mapping>mySQL</type-mapping> <!-- 数据库类型映射,这里保持默认即可 --> </datasources> ``` - **放置位置**: 修改后的 `mysql-ds.xml` 文件需要放置到 `tobeyou**\server\default\deploy` 目录下。 ...
### 通过SSIS导入数据(SQL Server2005→Oracle11g) #### 一、概述 在数据集成和迁移场景中,SQL Server Integration Services (SSIS) 是一种非常强大的工具,它允许用户轻松地从不同的数据源抽取、转换和加载...
SQLServer data provider Data type mapping from Varbinary type to Blob field is added Bug with data type mapping from MONEY type to TBCDField field is fixed Bug with AV failure on project compilation ...
SQLServer data provider Data type mapping from Varbinary type to Blob field is added Bug with data type mapping from MONEY type to TBCDField field is fixed Bug with AV failure on project compilation ...
Sql Server,DB2, Oracle, Access, Ase, Query by object,Paging, criteria, Mapping behaviour, mutil connection support, Data save and get, No XML mapping. Supports all of C#, C++ and VB languages. ...
1. Supports Oracle, SqlServer, PostgreSQL, MySQL, SQLite, Sybase, Ingres, CUBRID 2. Can generate hbm.xml, Fluent NHibernate and NH 3.3 Fluent style of mapping files. 3. Has lots of preferences to ...
-Data type mapping from RAW(16) to ftGuid is added -Now result parameter detection in UniConnection.ExecSQL is similar to the one in ODAC -Bug with connection establishing if the client has negative ...
Chapter 12 - Oracle, SQLXML, and Other .NET Data Providers Chapter 13 - Developing a Custom Data Provider Chapter 14 - Developing Database Web Applications using ASP.NET Chapter 15 - Using ADO...
CREATE SERVER ora_client_dw1 FOREIGN DATA WRAPPER oracle_fdw OPTIONS (dbserver '//134.132.9.7:1521/dw'); CREATE USER MAPPING FOR postgres SERVER ora_client_dw1 OPTIONS (user 'dw', password 'xxxx'); ...
Bug with updating fields which have data type mapping in TVirtualQuery is fixed Oracle data provider Oracle 18c is supported Implicit result sets in Oracle 12 are supported Bug with detecting time ...
Chapter 11 - Stored Procedures and Views Chapter 12 - Oracle, SQLXML, and Other .NET Data Providers Chapter 13 - Developing a Custom Data Provider Chapter 14 - Developing Database Web ...
Bug with updating fields which have data type mapping in TVirtualQuery is fixed Oracle data provider Oracle 18c is supported Implicit result sets in Oracle 12 are supported Bug with detecting time ...
v8.0.1 RAD Studio 10.3 Rio is supported Support of UPPER and LOWER functions for Unified SQL is added Bug with using the FieldOrigins property is fixed Bug with using the TrimFixedChar property is ...
v8.0.1 RAD Studio 10.2 Tokyo is supported Support of UPPER and LOWER functions for Unified SQL is added Bug with using the FieldOrigins property is fixed Bug with using the TrimFixedChar property is ...
在数据访问方面,OracleHelper可能支持ADO.NET、ODP.NET(Oracle Data Provider for .NET)等多种.NET框架下的数据访问技术。ADO.NET提供了基础的数据访问接口,而ODP.NET是Oracle官方提供的专用.NET数据提供者,它...
SQLServer data provider Bug with incorrect committing of data by the Loader component on errors is fixed MySQL data provider Bug with connecting in the Direct mode under Windows 2000 and lower is ...
<type-mapping>Oracle9i</type-mapping> <min-pool-size>10 <max-pool-size>30 <blocking-timeout-millis>60000 <idle-timeout-minutes>2 <new-connection-sql>SELECT COUNT(*) FROM dual</new-connection-...
要向Oracle数据库写入Blob数据,我们首先需要加载Oracle的JDBC驱动,建立数据库连接,然后创建PreparedStatement对象来执行SQL插入语句。插入语句通常包含一个占位符(?),对应于Blob类型的值。在执行前,我们需要...
- **支持多数据库**:除了 SQL Server 外,EF 还支持 Oracle、MySQL 等多种数据库系统。 - **性能与复杂度权衡**:虽然 EF 提供了更多的灵活性,但这种灵活性是以牺牲一定的性能和增加一定的复杂性为代价的。 ###...