我将一些数据类型从SQL服务器映射到cassandra,例如int到bigint,real到float,varchar到text。我在哪里可以获得从SQL服务器到cassandra的映射?
答案 0 :(得分:2)
查看与CQL Data Types相比较的SQL Server Data Types描述,这里有一些映射,但是没有保证(考虑到CQL数据类型参考中的拼写错误并不过分自信)它们是准确的。
比较不考虑SQL Server上用于更改数据类型表示的设置,例如具有字符数据类型的排序规则集,或者您如何转换并将此数据传递给SQL Server。
我根据可由两种类型表示的值进行比较。密切关注评论。
CQL Data Type | Match? | SQL Server Data Type | Comment ------------------------------------------------------------------------------------- list N none A collection; no native SQL equivalent. Perhaps sql_variant or XML could be used but operations on list in CQL wouldn't apply in SQL Server. Custom data types and CLR integrations would most likely be required map N none Similar to above except as of SQL Server 2016, [JSON Data](https://msdn.microsoft.com/en-gb/library/dn921897.aspx) handling has been introduced so it's possible it could parse CQL maps set N none " int Y int Both represent 32-bit signed integers bigint Y bigint Both represent 64-bit signed integers varint ? smallint Not clear if varint storage size will change, so if precision was -32768 to 32767, would it take 2 bytes? Also, if varint has values outside of smallint range, you may run into overflow errors. From smallint to varint, there's no indication in the above links varint ? tinyint Similar to above except if precision was 0 to 255, would it take 1 bytes? float Y float decimal ? decimal Not clear of the precision and scaling limits of CQL decimal ascii ? char, varchar Not clear this mapping is accurate, more an assumption. Limits and conversion behaviour are not known text ? ntext Based on UTF-8 encoding and that CQL seems to have varchar/text as does SQL. So it's likely text represents larger length text strings varchar ? nchar, nvarchar Based on UTF-8 encoding supported by both. Not clear what varchar limits are or the conversion behaviour timestamp ? datetime Not clear what timestamp limits are or the conversion behaviour boolean ? bit Not clear on conversion behaviour blob ? binary, varbinary Not clear what the limits are on length of a CQL blob uuid ? uniqueidentifier uuid follows standard UUID format, most likely 128 bits (16 bytes) which is the same storage size as uniqueidentifier. Not clear on the conversion behaviour