Home Database Mysql Tutorial 字符集与Oracle导出导入问题总结

字符集与Oracle导出导入问题总结

Jun 07, 2016 pm 05:02 PM
data

此处主要是关于NLS_LANG这个环境变量的说明,客户端依据其最先找到的NLS_LANG作为参考字符集,顺序为:用户级环境变量,系统级环

一 字符集与导出导入问题总结

    首先是必须保证Oracle的数据库服务端与客户端字符集一致,这样就能保证数据编码的一致性。

当数据库服务端选用ZHS16GBK时,当导出导入新的数据过程中,数据库服务端会对导入的二进制数据库作ZHS16GBK编码检查,当数据长度为奇数值时,出现数据的最后一个字节对应十进制为:129到254时,会丢失此字节,具体解释见第二节内容。

当数据库服务端选用WE8ISO8859P1时,当导出导入新的数据过程中,数据库服务端会对导入的二进制数据库作WE8ISO8859P1编码检查,逐个字节内容进行,不会有数据丢情况发生,具体解释见第二节内容;

针对在不同的字符集下将密文表数据进行导出导入后会有数据丢失的情况,下面作详细描述。

 

二 ZHS160GBK与WE8ISO8859P1字符集说明

对于上面提到的两种字符集,ZHS16GBK是Windows系统安装Oracle时,默认的数据库字符集,WE8ISO8859P1是Linux系统的默认安装的数据库字符集。且两种字符集都支持中文,至于国家字符集的选择,这里我们都是选择AF16UTF16。数据库安装完成后,可以用 select userenv('language') from dual 语句进行查看。对于ZHS16GBK字符集,数据库按双字节进行处理,且当字节对应的十进制数从129到254时,Oracle会按双字节处理,从而查找下一个字节内容,两个字节组成一个整体进行处理;但对WE8ISO8859P1,数据库完全是按单字节进行处理,所以不会有什么字节检查。

 

三当数据库为ZHS16GBK的情况描述

1 数据库端配置

在Windows下我们使用默认的Oracle安装,当要DBCoffer正常工作时,需对listener.ora进行修改,其参考配置如下:

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = ljb)

      (ORACLE_HOME = E:\oracle\product\10.2.0\db_1)

    )

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = E:\oracle\product\10.2.0\db_1)

      (ENVS = EXTPROC_DLLS=ANY)

      (PROGRAM = extproc)

    )

  )

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = extproc))

      (ADDRESS = (PROTOCOL = TCP)(HOST = Jiabo)(PORT = 1521))

    )

  )

表1

 

关于此种情况下的Oracle客户端环境变量的设置,可以在注册表查找到:

NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK

 

2 加密解密情况描述

正常安装DBCoffer完成后,便可以正常加密解密数据

 

3 导出导入情况描述

   当加密一个表后,我们知道加密后的密文长度都是一个奇数值,当将密文表用exp命令导出数据库后,然后将原密文表重命名,而后将导出的数据导入数据库,此时会出现的情况是密文字段部分数据的最后一个字节内容丢失,当再次将此时导入的密文表再次导出去,并且与原导出的表的二进制文件进行比较时,明显数据对不上,且丢失的字节大小范围都在对应的十进制的129到254,那么这样一来,就可以确定是数据库字符集处理产生的问题,因为密文长度是一个奇数值,假如当密文的数据的最后一个字节内容为129到254时,会出现如前面所描述的情况发生,Oracle服务端会将最后一个字节作双字节处理,如果找不到下一

个字节,则将此字节丢失。

关于以上情况:我们可以用lengthb(密文字段)去查看,原密文表的密文长度都是一个固定的奇数值,而再次导入表密文表的密文字段有部分是比该奇数值小1的,所以针对密文表的查询会报-10004,加密数据不完整。

 

四当数据库为WE8ISO8859P1的情况描述

1 新建一个Oracle数据库实例iso8859

此步可以利用DBCA工具进行,当进行至第十步时,按下图所示设置数据库字符集。

图 1

 

 

2 修改Oracle的listener.ora和tnames.ora的配置

  关于listener.ora的配置参考如下:

# listener.ora Network Configuration File: E:\oracle\product\10.2.0\db_1\network\admin\listener.ora

# Generated by Oracle configuration tools.

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = ljb)

      (ORACLE_HOME = E:\oracle\product\10.2.0\db_1)

    )

    (SID_DESC =

      (SID_NAME = iso8859)

      (ORACLE_HOME = E:\oracle\product\10.2.0\db_1)

    )

    (SID_DESC =

      (SID_NAME = orcl)

      (ORACLE_HOME = E:\oracle\product\10.2.0\db_1)

    )

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = E:\oracle\product\10.2.0\db_1)

      (ENVS = "EXTPROC_DLLS=ANY,ODC_SECURE_SERVICE_API_CONFIG_FILE=C:\DBCoffer\DBCSecureServiceAPI\secureServiceAPI.conf,NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1")

      (PROGRAM = extproc)

    )

  )

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = extproc))

      (ADDRESS = (PROTOCOL = TCP)(HOST = Jiabo)(PORT = 1521))

    )

  )

 

表2

 

其中请一定注意红色部分的内容,如果用Net Manager修改相关配置后,也请以此文件为参考,否则有可能我们的DBCoffer可能不能正常工作,而在tnames.ora的配置就相对较简单,添加如下内容即可:

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Use ddrescue to recover data on Linux Use ddrescue to recover data on Linux Mar 20, 2024 pm 01:37 PM

DDREASE is a tool for recovering data from file or block devices such as hard drives, SSDs, RAM disks, CDs, DVDs and USB storage devices. It copies data from one block device to another, leaving corrupted data blocks behind and moving only good data blocks. ddreasue is a powerful recovery tool that is fully automated as it does not require any interference during recovery operations. Additionally, thanks to the ddasue map file, it can be stopped and resumed at any time. Other key features of DDREASE are as follows: It does not overwrite recovered data but fills the gaps in case of iterative recovery. However, it can be truncated if the tool is instructed to do so explicitly. Recover data from multiple files or blocks to a single

Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Apr 03, 2024 pm 12:04 PM

0.What does this article do? We propose DepthFM: a versatile and fast state-of-the-art generative monocular depth estimation model. In addition to traditional depth estimation tasks, DepthFM also demonstrates state-of-the-art capabilities in downstream tasks such as depth inpainting. DepthFM is efficient and can synthesize depth maps within a few inference steps. Let’s read about this work together ~ 1. Paper information title: DepthFM: FastMonocularDepthEstimationwithFlowMatching Author: MingGui, JohannesS.Fischer, UlrichPrestel, PingchuanMa, Dmytr

How to use Excel filter function with multiple conditions How to use Excel filter function with multiple conditions Feb 26, 2024 am 10:19 AM

If you need to know how to use filtering with multiple criteria in Excel, the following tutorial will guide you through the steps to ensure you can filter and sort your data effectively. Excel's filtering function is very powerful and can help you extract the information you need from large amounts of data. This function can filter data according to the conditions you set and display only the parts that meet the conditions, making data management more efficient. By using the filter function, you can quickly find target data, saving time in finding and organizing data. This function can not only be applied to simple data lists, but can also be filtered based on multiple conditions to help you locate the information you need more accurately. Overall, Excel’s filtering function is a very practical

Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Apr 01, 2024 pm 07:46 PM

The performance of JAX, promoted by Google, has surpassed that of Pytorch and TensorFlow in recent benchmark tests, ranking first in 7 indicators. And the test was not done on the TPU with the best JAX performance. Although among developers, Pytorch is still more popular than Tensorflow. But in the future, perhaps more large models will be trained and run based on the JAX platform. Models Recently, the Keras team benchmarked three backends (TensorFlow, JAX, PyTorch) with the native PyTorch implementation and Keras2 with TensorFlow. First, they select a set of mainstream

Slow Cellular Data Internet Speeds on iPhone: Fixes Slow Cellular Data Internet Speeds on iPhone: Fixes May 03, 2024 pm 09:01 PM

Facing lag, slow mobile data connection on iPhone? Typically, the strength of cellular internet on your phone depends on several factors such as region, cellular network type, roaming type, etc. There are some things you can do to get a faster, more reliable cellular Internet connection. Fix 1 – Force Restart iPhone Sometimes, force restarting your device just resets a lot of things, including the cellular connection. Step 1 – Just press the volume up key once and release. Next, press the Volume Down key and release it again. Step 2 – The next part of the process is to hold the button on the right side. Let the iPhone finish restarting. Enable cellular data and check network speed. Check again Fix 2 – Change data mode While 5G offers better network speeds, it works better when the signal is weaker

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks Apr 29, 2024 pm 06:55 PM

I cry to death. The world is madly building big models. The data on the Internet is not enough. It is not enough at all. The training model looks like "The Hunger Games", and AI researchers around the world are worrying about how to feed these data voracious eaters. This problem is particularly prominent in multi-modal tasks. At a time when nothing could be done, a start-up team from the Department of Renmin University of China used its own new model to become the first in China to make "model-generated data feed itself" a reality. Moreover, it is a two-pronged approach on the understanding side and the generation side. Both sides can generate high-quality, multi-modal new data and provide data feedback to the model itself. What is a model? Awaker 1.0, a large multi-modal model that just appeared on the Zhongguancun Forum. Who is the team? Sophon engine. Founded by Gao Yizhao, a doctoral student at Renmin University’s Hillhouse School of Artificial Intelligence.

Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! May 06, 2024 pm 04:13 PM

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training Mar 11, 2024 pm 12:10 PM

This week, FigureAI, a robotics company invested by OpenAI, Microsoft, Bezos, and Nvidia, announced that it has received nearly $700 million in financing and plans to develop a humanoid robot that can walk independently within the next year. And Tesla’s Optimus Prime has repeatedly received good news. No one doubts that this year will be the year when humanoid robots explode. SanctuaryAI, a Canadian-based robotics company, recently released a new humanoid robot, Phoenix. Officials claim that it can complete many tasks autonomously at the same speed as humans. Pheonix, the world's first robot that can autonomously complete tasks at human speeds, can gently grab, move and elegantly place each object to its left and right sides. It can autonomously identify objects

See all articles