如果它是主键并且被索引,如何更改列的数据类型?

How to change the data type of a column if it is the primary key and is indexed?

我正在使用 IBExpert 来操作我的数据库。我有一个旧的 table 有两个字段:

 - code (char 3)  PK + INDEX
 - name (varchar 30)

新的table应该是

 - code (integer) PK + INDEX
 - name (varchar 30)

即使是char类型,code栏的数据也只有数字。

是否可以更改代码列的类型?如果是如何?我假设我需要删除主键并删除或停用索引,但 IBExpert 不允许我这样做,并在我尝试删除 PK 时给我这个错误:object INDEX is in use

错误object INDEX is in use 准确的意思是:对象正在使用中,例如在准备语句的查询计划中。为了能够修改它,您需要确保没有任何对象对该对象持有存在锁,最简单的方法是 shutdown the database using gfix,进行更改并再次将数据库设置为联机。