如何更改 firebird3 中的列类型
How change a column type in firebird3
从 firebird 3 开始,我无法修改列类型
在我使用这种更新之前:
update RDB$RELATION_FIELDS set
RDB$FIELD_SOURCE = 'MYTEXT'
where (RDB$FIELD_NAME = 'JXML') and
(RDB$RELATION_NAME = 'XMLTABLE')
因为我收到 ISC 错误 335545030。
也许 firebird 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 2.5 手册
ALTER TABLE tabname ALTER COLUMN colname TYPE typename
从 firebird 3 开始,我无法修改列类型
在我使用这种更新之前:
update RDB$RELATION_FIELDS set
RDB$FIELD_SOURCE = 'MYTEXT'
where (RDB$FIELD_NAME = 'JXML') and
(RDB$RELATION_NAME = 'XMLTABLE')
因为我收到 ISC 错误 335545030。
也许 firebird 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 2.5 手册
ALTER TABLE tabname ALTER COLUMN colname TYPE typename