Specifying VARCHAR and NVARCHAR size for db targets #121
-
Hi! Curious if it's possible to specify the length of VARCHAR and NVARCHAR columns when using a db (sql server specifically) as a target. Ideally on a per column level too. Thanks! Awesome tool too! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Hey @cody-scott, just curious, can you share on the reasoning for your use case? Since Sling automatically determines the varchar length needed per column basis. Here is the mapping of all types into respective databases: https://github.com/flarco/dbio/blob/main/database/templates/types_general_to_native.tsv As you can see, for SQL Server, |
Beta Was this translation helpful? Give feedback.
K I see. Yes, Oracle uses
NUMBER
for integers and decimals, so sling defaults that to decimals. And I'm guessing the string columns areCLOB
orBLOB
? Those get mapped to thetext
general type which translates toNVARCHAR(MAX)
, since those are usually large values.Indeed your best bet is to define the
source.options.columns
, where you can specifyinteger
/bigint
for the PKs, andstring
for the others if you don't wanttext
/NVARCHAR(MAX)
for them. Sling will determine the proper length and auto createNVARCHAR({length})
columns. A suggestion is to define those in thedefaults
section in the Replication YAML (if the column names are re-used across many tables, typical for PKs).