新建产品库mydb6_product:
mysql> create database mydb6_product;
mysql> use mydb6_product;
建立employees表:
mysql> create table employees(id int primary key, name varchar(50) not null, age int, gender varchar(10) not null default 'unknown', salary float);
创建orders表:
mysql> create table orders(id int primary key, name varchar(100) not null, price float, quantity int, category varchar(50));
建立invoices表:
mysql> create table invoices(number int primary key, order_id int, foreign key (order_id) references orders (id), in_date date, total_amount float); //外键关联到orders表的id列
mysql> alter table invoices modify number int auto_increment; //主键自增长