2016-08-26 3 views
-2

Я сопоставляю некоторые типы данных с SQL-сервера в cassandra, такие как int to bigint, real to float, varchar to text. Где я могу получить сопоставления с SQL-сервера в cassandra?SQL vs Cassandra Отображение типов данных

+0

Необходимо определить, какие типы данных использовать. Для этого не существует стандарта. –

ответ

1

Рассматривая 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 
Смежные вопросы