我正在尝试使用SQL代码来创建大型数据库。
This是我的源文件
我尝试在seeds.rb文件中执行此代码
connection = ActiveRecord::Base.connection()
connection.execute("
CREATE TABLE `VehicleModelYear` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`year` INT(4) UNSIGNED NOT NULL,
`make` VARCHAR(50) NULL,
`model` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE `U_VehicleModelYear_year_make_model` (`year`, `make`, `model`),
INDEX `I_VehicleModelYear_year` (`year`),
INDEX `I_VehicleModelYear_make` (`make`),
INDEX `I_VehicleModelYear_model` (`model`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
")
它给了我错误:
ActiveRecord::StatementInvalid: SQLite3::SQLException: near "AUTO_INCREMENT": syntax error
我使用验证器检查了SQL代码,没有发现错误。
任何提示?
谢谢!