考虑下表,其中大约有 10M 行
CREATE TABLE user
(
id bigint NOT NULL,
...
CONSTRAINT user_pk PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
)
然后我应用了以下更改
ALTER TABLE USER ADD COLUMN BUSINESS_ID VARCHAR2(50);
--OK
UPDATE USER SET BUSINESS_ID = ID; //~1500 sec
--OK
ALTER TABLE USER ALTER COLUMN BUSINESS_ID SET NOT NULL;
ERROR: column "business_id" contains null values
SQL state: 23502
这很奇怪,因为 id 列(已复制到 business_id 列)不能包含空值,因为它是主键,但要确保我检查它
select count(*) from USER where BUSINESS_ID is null
--0 records
我怀疑这是一个错误,只是想知道我是否遗漏了一些琐碎的事情