snippetsqlMinor
Create table in Oracle as select from SQL Server - varchar size
Viewed 0 times
oraclecreatesqlsizevarcharserverselectfromtable
Problem
I am trying to create table in Oracle 11g as select from a table in SQL Server 2012 via database link.
The table in SQL Server contains column:
In Oracle it created the table with the same column but different size:
This behavior causes me a lot of problems with the columns size in Oracle.
How can I prevent Oracle from increasing the column size?
The table in SQL Server contains column:
hslakkis varchar(3)In Oracle it created the table with the same column but different size:
hslakkis varchar2(9)This behavior causes me a lot of problems with the columns size in Oracle.
How can I prevent Oracle from increasing the column size?
Solution
This is a feature that's controllable by a parameter. From the documentation:
Multi-byte Character Sets Ratio Suppression This feature optionally suppresses the ratio expansion from SQL Server database to
Oracle database involving multi-byte character set. By default, Oracle
gateways assume the worst ratio to prevent data being truncated or
insufficient buffer size situation. However, if you have specific
knowledge of your SQL Server database and do not want the expansion to
occur, you can specify HS_KEEP_REMOTE_COLUMN_SIZE parameter to
suppress the expansion.
Basically, Oracle is assuming that all of the data in the source table may take up 3 bytes per character, due to characterset conversion.
Multi-byte Character Sets Ratio Suppression This feature optionally suppresses the ratio expansion from SQL Server database to
Oracle database involving multi-byte character set. By default, Oracle
gateways assume the worst ratio to prevent data being truncated or
insufficient buffer size situation. However, if you have specific
knowledge of your SQL Server database and do not want the expansion to
occur, you can specify HS_KEEP_REMOTE_COLUMN_SIZE parameter to
suppress the expansion.
Basically, Oracle is assuming that all of the data in the source table may take up 3 bytes per character, due to characterset conversion.
Context
StackExchange Database Administrators Q#124251, answer score: 5
Revisions (0)
No revisions yet.