要求
设置过程
mysql> create table employees (id int primary key ,
-> name varchar(50) not null,
-> age int ,
-> gender varchar(10) not null default"unknown",
-> salary float );
mysql> create table orders (id int primary key,
-> name varchar(100) not null ,
-> price float ,
-> quantity int ,
-> category varchar(50);
mysql> create table invoices (number int primary key ,
-> order_id int ,foreign key (order_id) references orders(id),
-> total_amount float );
设置主键自增长
mysql> alter table invoices modify number int auto_increment ;
、
结果![](https://i-blog.csdnimg.cn/direct/43f475422eda4d7c9dc1524cc613ca9c.png)
sql8.0安装