我正在使用代码优先方法,并且我想数据库侧字符串的默认类型是nvarchar(),但是我发现的是nclob,它比nvarchar大,我不知道为什么。>
这是我的模型的一部分:
public string Name { get; set; }
public string En_Name { get; set; }
这是它的配置:
this.Property(p => p.Name).HasMaxLength(200).IsOptional();
this.Property(p => p.En_Name).HasMaxLength(50).IsOptional();
我需要它是nvarchar而不是nclob
答案 0 :(得分:0)
我不会说您使用的语言。
但是,从Oracle的角度来看:如果列数据类型为NCLOB,则不能仅将其 modify 修改为NVARCHAR2(如果您要这样做)。虽然,有一种方法可以做到。这是一个示例:
SQL> create table test (col nclob);
Table created.
SQL> insert into test values ('x');
1 row created.
SQL> alter table test modify col nvarchar2(20);
alter table test modify col nvarchar2(20)
*
ERROR at line 1:
ORA-22859: invalid modification of columns
SQL>
好的,那样行不通。因此:
。
SQL> alter table test add col_vc nvarchar2(20);
Table altered.
SQL> update test set col_vc = dbms_lob.substr(col, 20, 1);
1 row updated.
SQL> alter table test drop column col;
Table altered.
SQL> alter table test rename column col_vc to col;
Table altered.
SQL> desc test
Name Null? Type
----------------------------------------- -------- ----------------------------
COL NVARCHAR2(20)
SQL> select * From test;
COL
--------------------
x
SQL>
现在您有了NVARCHAR2列,因此-希望您的代码可以正常工作。
如果上述方法不起作用(因为不允许您修改列的数据类型),我想其他人将不得不提供帮助。