This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/DB/exp1.sql
2023-04-13 12:17:26 +08:00

42 lines
1.6 KiB
SQL

create database eshop4490;
create table members(
m_account varchar(20) primary key,
m_name varchar(20),
m_sex varchar(2),
m_address varchar(50),
m_salary money,
m_password varchar(20)
);
create table products(
p_no char(10) primary key,
p_name varchar(30),
p_quantity int,
p_price money,
p_information varchar(50)
);
create table orders(
m_account varchar(20) references members(m_account),
p_no char(10) references products(p_no),
o_quantity int,
o_date date,
primary key (m_account,p_no)
);
insert into members values ('jin', '刘津', '', '北京', 8200, 'jin'),
('lfz', '刘法制', '', '天津', 4500, 'lfz'),
('jinjin', '津津', '', '北京', 8200, 'jin'),
('liuzc', '刘志成', '', '湖南株洲', 3500,'liuzc'),
('Wangym', '王咏梅', '', '湖南长沙', 4000, 'wangym');
insert into products values ('101', '香皂', 22, 6, '清洁用品'),
('102', '牙刷', 10, 20, '价廉物美'),
('103', 'MP3', 100, 450, '电子产品'),
('104', '毛巾', 10,15, '价廉物美');
insert into orders values ('lfz', '101', 5, '2017-8-9'),
('Wangym', '101',9, '2017-6-6'),
('jinjin', '102', 6, '2017-6-6'),
('liuzc', '102', 4, '2017-8-9'),
('Wangym', '103', 7, '2017-8-9'),
('jinjin', '103', 6, '2017-8-9');
update members set m_salary = m_salary * 1.2 WHERE m_sex = '' and m_address ='北京';