-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path插入数据.sql
67 lines (54 loc) · 1.21 KB
/
插入数据.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
show databases;
use librarymanagementsystem;
show tables;
-- 读者表
-- 从txt导入数据
load data local infile '/home/nomad/Desktop/testin_reader.txt'
into table Reader;
-- 导出数据到txt(存在权限错误,修改了还是错误,导出到/tmp也出错)
select *
into outfile '//home/nomad/Desktop/testout.txt'
lines terminated by '/r/n'
from Reader;
show warnings;
describe Lend;
select *
from Reader;
select Lend.*, Rname from Lend, Reader where Lend.Rno = Reader.Rno and Lend.Rno = 9;
delete
from Reader;
drop table Lend;
truncate Reader;
-- 图书表
describe Book;
-- 从txt导入数据
load data local infile '/home/nomad/Desktop/testin_book.txt'
into table Book;
show warnings;
select *
from Book;
-- 借阅信息表
describe Lend;
-- 从txt导入数据
load data local infile '/home/nomad/Desktop/testin_lend.txt'
into table Lend;
select *
from Lend;
insert
into Lend
values(10, 1, '2016-11-11', '2016-12-12', -1);
update Lend
set Quantity = Quantity + 1
where Bno = 2 and Rno = 2;
select Lend.*, Rname
from Lend, Reader
where Lend.Rno = Reader.Rno and
Lend.Rno = 2;
-- 登录用户信息表
describe MUser;
insert
into MUser(Uname, Ukey)
values('user1', '001', 0);
select *
from MUser;
truncate MUser;