在MySQL表中插入数据的查询包含外键,可以通过以下步骤完成:
CREATE TABLE orders (
id INT PRIMARY KEY,
order_number INT,
customer_id INT,
FOREIGN KEY (customer_id) REFERENCES customers(id)
);
INSERT INTO orders (id, order_number, customer_id)
VALUES (1, 1001, 1);
外键的优势:
外键的应用场景:
腾讯云相关产品推荐:
领取专属 10元无门槛券
手把手带您无忧上云