firebird - 如何在firebird3中更改列类型

标签 firebird firebird-3.0

由于firebird 3,我无法修改列类型

在使用这种更新之前:

update RDB$RELATION_FIELDS set
RDB$FIELD_SOURCE = 'MYTEXT'
where (RDB$FIELD_NAME = 'JXML') and
(RDB$RELATION_NAME = 'XMLTABLE')

因为我收到ISC错误335545030。

也许在火鸟3中还有另一种方法?

最佳答案

Firebird 3不再允许直接更新系统表,因为这是可能损坏数据库的一种方式。另请参见发行说明中的​​System Tables are Now Read-only。您将需要使用DDL语句进行修改。
看起来您想将列的数据类型更改为域。您将需要为此使用 alter table ... alter column ... 。具体来说,您需要执行以下操作:

alter table XMLTABLE
    alter column JXML type MYTEXT;
这确实有一些限制:

Changing the Data Type of a Column: the TYPE Keyword

The keyword TYPE changes the data type of an existing column to another, allowable type. A type change that might result in data loss will be disallowed. As an example, the number of characters in the new type for a CHAR or VARCHAR column cannot be smaller than the existing specification for it.

If the column was declared as an array, no change to its type or its number of dimensions is permitted.

The data type of a column that is involved in a foreign key, primary key or unique constraint cannot be changed at all.


从Firebird 1(InterBase 6.0)开始,此语句就可用了。

关于firebird - 如何在firebird3中更改列类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48267131/

相关文章:

sql - 如何组合一个查询使用 MIN 函数的 sql 查询

sql - Firebird 中的 token 未知

c++ - 用于加密/解密的 Firebird 数据库 UDF 不释放内存

delphi - 如何在函数内添加查询

firebird - 生成数字范围的最快方法

sql - Firebird 多重声明

firebird - Firebird 数据库文件是否与 Firebird Embedded 数据库兼容

c - 如何使用结构创建数据库表

sql - 用联接更新表?