创建表时使用快捷查询分配主键的正确方法是什么?
这是我的快捷方式的示例:
create table booking_product (
`id` int(10) not null constraint `booking_product_id` primary key auto_increment ,
`bookingId` int(10) not null,
`serviceId` int(10) not null,
`date` date not null,
`price` decimal(30,15) not null,
`qty` int(1) not null,
`currencyId` int(10) not null,
`total` decimal(30,15) not null,
`roomInclusion` text null default null,
foreign key booking_product(bookingId) references booking(id) on update cascade on delete cascade,
foreign key booking_product(serviceId) references service(id) on update cascade on delete set null,
foreign key booking_product(currencyId) references currency(id) on update cascade on delete set null
) engine = InnoDB;
- 注意第 2 行我尝试分配主键,但是这个查询是错误的并产生错误。如果我尝试只使用
id int(10) not null primary key auto_increment ,
我会得到错误:Duplicate key name 'booking_product'