简体   繁体   English

SQL Server上的数据迁移文本类型

[英]Data Migration Text Type on SQL Server

I'm trying to use the database-migration plugin for Grails, but I'm running into a funky problem with property types of text . 我正在尝试为Grails使用数据库迁移插件 ,但是我遇到了text属性类型的时髦问题。

Generating a baseline log is setting the type as text(255) , but this is an error because there is no precision. 生成基线日志会将类型设置为text(255) ,但这是错误的,因为没有精度。 The same happens when I try to modify datatype to text . 当我尝试将数据类型修改为text时,也会发生同样的情况。

changeSet(author: "jgiotta (generated)", id: "1348767652354-2") {
    modifyDataType(columnName: "old_value", newDataType: "text",
        schemaName: "dbo", tableName: "audit_trail")
}

What can I do to avoid this issue? 我应该怎么做才能避免这个问题?

Check the character set setting on the connection driver (ODBC/JDBC). 检查连接驱动程序(ODBC / JDBC)上的字符集设置。
I had similar issue when bringing NVARCHAR field over using a replication tool. 将NVARCHAR字段用于复制工具时,我遇到了类似的问题。 Nulls were being written to target because the ODBC driver didn't understand NVARCHAR with ASCII character map. 空值被写入目标,因为ODBC驱动程序不理解ASCII字符映射的NVARCHAR。 In short, issue was that the replication tool was using ODBC driver with ASCII character set. 简而言之,问题在于复制工具正在使用带ASCII字符集的ODBC驱动程序。 Once, I changed the ODBC driver to use UTF8 character set, I started seeing NVARCHAR data on target. 一次,我将ODBC驱动程序更改为使用UTF8字符集,开始在目标上看到NVARCHAR数据。

I solved it with a little bit of additional mapping. 我通过一点点附加映射解决了它。

Originally I was only doing: 本来我只是在做:

static mapping = {
    oldValue type: 'text'
    //...
}

What forced the type to at least nvarchar(max) was the following mapping: 迫使类型至少为nvarchar(max)是以下映射:

static mapping = {
    oldValue type: 'text', sqlType: 'text'
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM