我正在尝试在file_name
列上创建一个非唯一索引。我预计会有很高的基数,比如说1,000行数据中,有950个不同的文件名。
file_collection = Table ('file_collection', metadata,
Column('id', Integer, primary_key=True),
Column('full_path', String, unique=True, nullable=False),
Column('file_name', String, index=True, nullable=False)
)
我的方言是sqlite。当我创建表时,file_name
列上不会创建非唯一键。
CREATE TABLE file_collection (
id INTEGER NOT NULL,
full_path VARCHAR NOT NULL,
file_name VARCHAR NOT NULL,
PRIMARY KEY (id),
UNIQUE (full_path)
)
我该如何在
file_name
列上创建一个非唯一键?
engine = create_engine('sqlite:///test.db', echo=True)
。 - user784637