示例(Microsoft SQL 服务器):
CREATE TABLE test_index
(
col INT NOT NULL,
col2 INT NOT NULL,
col3 INT NOT NULL UNIQUE,
col4 VARCHAR(200)
);
CREATE UNIQUE INDEX aaaa ON test_index (col, col2);
ALTER TABLE test_index
DROP COLUMN col;
您不能删除 col
列,因为它在索引表中。 要删除列,需要先删除 aaaa
索引(例如 DROP INDEX aaaa)。