テーブルの作成中にショートカットクエリで主キーを割り当てる正しい方法は何ですか?
これが私のショートカットの例です:
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'