<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DTS &#8211; 良的世界</title>
	<atom:link href="https://www.lemonary.cn/tag/dts/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lemonary.cn</link>
	<description></description>
	<lastBuildDate>Fri, 10 Jan 2025 07:03:05 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.lemonary.cn/wp-content/uploads/2024/12/profile-150x150.jpg</url>
	<title>DTS &#8211; 良的世界</title>
	<link>https://www.lemonary.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>MySQL数据库迁移到达梦数据库超出定义长度问题</title>
		<link>https://www.lemonary.cn/mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e8%bf%81%e7%a7%bb%e5%88%b0%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e8%b6%85%e5%87%ba%e5%ae%9a%e4%b9%89%e9%95%bf%e5%ba%a6%e9%97%ae%e9%a2%98/</link>
					<comments>https://www.lemonary.cn/mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e8%bf%81%e7%a7%bb%e5%88%b0%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e8%b6%85%e5%87%ba%e5%ae%9a%e4%b9%89%e9%95%bf%e5%ba%a6%e9%97%ae%e9%a2%98/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Fri, 10 Jan 2025 07:03:02 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[DM]]></category>
		<category><![CDATA[DTS]]></category>
		<category><![CDATA[LENGTH_IN_CHAR]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1324</guid>

					<description><![CDATA[一、问题背景 一般从MySQL迁移到DM数据库时，由于MySQL字符串的长度是以字符为单位，导致迁移过程中有可 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">一、问题背景</h2>



<p class="wp-block-paragraph">一般从MySQL迁移到DM数据库时，由于MySQL字符串的长度是以字符为单位，导致迁移过程中有可能遇到报错：超出定义长度。</p>



<p class="wp-block-paragraph">在DM8的早期阶段，针对从MySQL迁移至DM的场景，由于当时DM尚未原生支持变长字符类型（如VARCHAR(N CHAR)）的数据存储需求，故引入了LENGTH_IN_CHAR参数作为临时解决方案。旨在兼容并处理数据字符串截断的特定情境，确保迁移过程中的数据完整性。</p>



<p class="wp-block-paragraph">随着项目应用的深入及服务团队的持续反馈，LENGTH_IN_CHAR 参数的启用被发现与多种兼容性问题相关联，核心问题总结如下：</p>



<ol class="wp-block-list">
<li>LIKE查询异常
<ul class="wp-block-list">
<li>当数据库初始化配置为使用UTF-8字符集且不区分大小写，并激活 LENGTH_IN_CHAR 参数时，用户在执行 SELECT 语句采用 LIKE 模式匹配查询字符串时，曾遇到数据检索不准确的问题。</li>



<li>此问题已在DM8的 8.1.2.135 版本中得到修复。</li>
</ul>
</li>



<li>DBLINK查询字符集转换错误
<ul class="wp-block-list">
<li>在相似的配置环境下（UTF-8字符集，不区分大小写，启用 LENGTH_IN_CHAR ），通过数据库链接（DBLINK）执行 SELECT 查询时，该参数导致内部字符集转换过程发生异常，引发了字符集截断错误。</li>



<li>此技术障碍亦已在DM8的 8.1.1.117 版本中获得解决。</li>
</ul>
</li>



<li>存储差异性问题
<ul class="wp-block-list">
<li>若数据库实例配置启用了 LENGTH_IN_CHAR 参数，且字段定义采用 VARCHAR(10)，不同字符集的采用将直接影响到实际可存储的数据量。</li>



<li>这进一步凸显了该参数对数据存储一致性可能产生的不利影响，具体表现依字符编码而异。</li>
</ul>
</li>
</ol>



<p class="wp-block-paragraph">综上所述，鉴于 LENGTH_IN_CHAR 参数引发的多方面兼容性和一致性问题，结合已有的版本更新修复情况，其停用被视为提升系统稳定性和兼容性的必要举措，并且在 8.1.3.167 版本正式废弃。</p>



<p class="wp-block-paragraph">本文就是介绍目前新版DM数据库MySQL利用DTS迁移到DM数据库避免超出定义长度问题的方法。</p>



<h2 class="wp-block-heading">二、DTS迁移MySQL</h2>



<h3 class="wp-block-heading">2.1 设置数据类型映射</h3>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="198" height="433" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-9.png" alt="" class="wp-image-1326" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-9.png 198w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-9-137x300.png 137w" sizes="(max-width: 198px) 100vw, 198px" /></figure>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="440" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-11-1024x440.png" alt="" class="wp-image-1328" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-11-1024x440.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-11-300x129.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-11-768x330.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-11.png 1506w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<ol class="wp-block-list">
<li>添加映射</li>



<li>配置：源数据类型名-VARCHAR，目的数据类型名-VARCHAR，强制为字符存储选择-是</li>



<li>保存</li>
</ol>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="440" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-12-1024x440.png" alt="" class="wp-image-1329" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-12-1024x440.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-12-300x129.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-12-768x330.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-12.png 1504w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">2.2 迁移过程</h3>



<p class="wp-block-paragraph">源端数据库</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="726" height="580" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-14.png" alt="" class="wp-image-1338" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-14.png 726w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-14-300x240.png 300w" sizes="auto, (max-width: 726px) 100vw, 726px" /></figure>



<p class="wp-block-paragraph">目的端数据库</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="726" height="580" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-15.png" alt="" class="wp-image-1339" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-15.png 726w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-15-300x240.png 300w" sizes="auto, (max-width: 726px) 100vw, 726px" /></figure>



<p class="wp-block-paragraph">迁移选项※</p>



<p class="wp-block-paragraph">取消单选框，不使用默认数据类型映射关系，便能调用到我们所配置的数据类型映射。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="966" height="673" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-16.png" alt="" class="wp-image-1340" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-16.png 966w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-16-300x209.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-16-768x535.png 768w" sizes="auto, (max-width: 966px) 100vw, 966px" /></figure>



<p class="wp-block-paragraph">指定模式</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="997" height="726" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-17.png" alt="" class="wp-image-1341" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-17.png 997w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-17-300x218.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-17-768x559.png 768w" sizes="auto, (max-width: 997px) 100vw, 997px" /></figure>



<p class="wp-block-paragraph">指定对象</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="640" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-18-1024x640.png" alt="" class="wp-image-1342" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-18-1024x640.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-18-300x187.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-18-768x480.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-18-1536x960.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-18.png 1930w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">审阅迁移任务</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="640" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-19-1024x640.png" alt="" class="wp-image-1343" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-19-1024x640.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-19-300x187.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-19-768x480.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-19-1536x960.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-19.png 1930w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">点击“完成”，进行迁移，即可完成数据类型的映射。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e8%bf%81%e7%a7%bb%e5%88%b0%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e8%b6%85%e5%87%ba%e5%ae%9a%e4%b9%89%e9%95%bf%e5%ba%a6%e9%97%ae%e9%a2%98/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
