一、要求
新建产物库mydb6_product,新建3张表,表结构如下:
二、实现步骤
1.创建数据库mydb6_product
创建命令: create database mydb6_product;
检察创建的数据库,命令:show databases;
2.创建employees表
创建命令:
1、首先需要使用数据库作为当前数据库:use mydb6_product;
2、创建二维表employees:
create table employees(
id int primary key,
name varchar(50) not null,
age int,
gender varchar(10) not null default 'unkwon',
salary float);
3.创建orders表
创建命令:
1、创建二维表orders:
create table orders(
id int primary key,
name varchar(100) not null,
price float,
quantity int,
category varchar(50));
4、创建invoices表
创建命令:
1、创建二维表invoices
create table invoices(
number int primary key auto_increment,
order_id int,
in_date date,
total_amount float,
foreign key(order_id) references orders(id),
check(total_amount>0) );
三、检察实现情况
1、检察表
命令:show tables;
2、检察表结构
表employees:
表invoices:
表orders:
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |