How to explicitly set the data type of a field in SQL generated tables?

 How to explicitly set the data type of a field in SQL generated tables?

Hi guys,

The following link has OutSystems Platform data types mapping to the data types of the database.

I need to explicitly set this data type. For example: Set a text attribute in the entity to generate a nvarchar(max) in the respective SQL Table. There's some guide or workaround to achieve this?

Hello André

As you can see in the refered link, if you create an entity attribute of type Text with 2000 or more of length, it will create a nvarchar(max) in the Oracle database for the correspondent column.

Does this answer your question?

Well as you might be aware that "The max size for a column of type NVARCHAR(MAX) is 2 GByte of storage.

Since NVARCHAR uses 2 bytes per character, that's approx. 1 billion characters."

If you anticipate data possibly exceeding 4000 character, nvarchar(MAX) is definitely the recommended choice.

@Miguel, it's exactly what I want to workaround. The platform always generate following that convention. But I can't have a field with nvarchar(3000) or char(x) on database, could I? (and thanks about the nvarchar(max) tip, it helps)

@Kayala, I agree with you, but the customer wants to have control and be able to customize this datatypes acording to its needs.  He wants, for example, to set a text with nvarchar(3000), or to char(5), etc. I'm trying to convince them to adopt the platform convention, but its always a complicated task...

Hello André,

The Platform will always create a NVARCHAR(n) where the n is the length of the text datatype in the entity attribute that ranges from 1 to 1999. For N >=2000 it will always generate the NVARCHAR(MAX).

There's no other way to generate different data types like NVARCHAR(3000). But since these are data models generated and maintained by the platform, why does the customer requires other specific datatypes? What's the driver to have these datatypes?

Hi Miguel,

I can't say exactly why the customer requires it, but it's some pattern that they had adopted to the DB, and the question came up about if would be possible to maintain that.

I'll follow this explanation to them.

Thanks for the help!