Skip to content

Commit 66fb888

Browse files
committed
更新了数据库部分相关知识
1 parent 02d3171 commit 66fb888

10 files changed

+1436
-218
lines changed

Day36-40/code/SRS_create_and_init.sql

Lines changed: 132 additions & 151 deletions
Large diffs are not rendered by default.

Day36-40/code/contact/main.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
"""
2+
-- 创建名为address的数据库
3+
create database address default charset utf8;
4+
5+
-- 切换到address数据库
6+
use address;
7+
8+
-- 创建联系人表tb_contacter
9+
create table tb_contacter
10+
(
11+
conid int auto_increment comment '编号',
12+
conname varchar(31) not null comment '姓名',
13+
contel varchar(15) default '' comment '电话',
14+
conemail varchar(255) default'' comment '邮箱',
15+
primary key (conid)
16+
);
17+
"""
118
import pymysql
219

320
INSERT_CONTACTER = """
@@ -154,9 +171,9 @@ def find_contacters(con):
154171

155172

156173
def main():
157-
con = pymysql.connect(host='localhost', port=3306,
174+
con = pymysql.connect(host='120.77.222.217', port=3306,
158175
user='root', passwd='123456',
159-
db='contact', charset='utf8',
176+
db='address', charset='utf8',
160177
autocommit=True,
161178
cursorclass=pymysql.cursors.DictCursor)
162179
while True:

Day36-40/code/contact/test01.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

Day36-40/code/contact/test02.py

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
drop database if exists Library;
1+
drop database if exists library;
22

3-
create database Library default charset utf8;
3+
create database library default charset utf8;
44

5-
use Library;
5+
use library;
66

7-
create table TbBook
7+
create table tb_book
88
(
99
bookid integer primary key auto_increment,
1010
title varchar(100) not null,
@@ -16,16 +16,16 @@ lenddate datetime,
1616
lendcount integer default 0
1717
);
1818

19-
insert into TbBook (title, author, publisher, price, lendcount) values ('Java核心技术(卷1)', '凯 S.霍斯特曼', '机械工业出版社', 98.2, 102);
20-
insert into TbBook (title, author, publisher, price, lendcount) values ('Java编程思想', '埃史尔', '机械工业出版社', 86.4, 87);
21-
insert into TbBook (title, author, publisher, price, lendcount) values ('深入理解Java虚拟机', '周志明', '机械工业出版社', 64.4, 32);
22-
insert into TbBook (title, author, publisher, price, lendcount) values ('Effective Java中文版(第2版) ', '埃史尔', '机械工业出版社', 36.8, 200);
23-
insert into TbBook (title, author, publisher, price, lendcount) values ('数据结构与算法分析:Java语言描述(原书第3版)', '马克·艾伦·维斯', '机械工业出版社', 51.0, 15);
24-
insert into TbBook (title, author, publisher, price, lendcount) values ('Java 8实战', '厄马', '人民邮电出版社', 56.8, 25);
25-
insert into TbBook (title, author, publisher, price, lendcount) values ('重构:改善既有代码的设计', '马丁·福勒', '人民邮电出版社', 53.1, 99);
26-
insert into TbBook (title, author, publisher, price, lendcount) values ('代码大全(第2版)', '史蒂夫•迈克康奈尔', '电子工业出版社', 53.1, 99);
27-
insert into TbBook (title, author, publisher, price, lendcount) values ('程序员修炼之道:从小工到专家', '亨特, 托马斯', '电子工业出版社', 45.4, 50);
28-
insert into TbBook (title, author, publisher, price, lendcount) values ('代码整洁之道', '马丁', '人民邮电出版社', 45.4, 30);
29-
insert into TbBook (title, author, publisher, price, lendcount) values ('设计模式 可复用面向对象软件的基础', 'Erich Gamma, Richard Helm', '机械工业出版社', 30.2, 77);
30-
insert into TbBook (title, author, publisher, price, lendcount) values ('设计模式之禅(第2版)', '秦小波', '机械工业出版社', 70.4, 100);
19+
insert into tb_book (title, author, publisher, price, lendcount) values ('Java核心技术(卷1)', '凯 S.霍斯特曼', '机械工业出版社', 98.2, 102);
20+
insert into tb_book (title, author, publisher, price, lendcount) values ('Java编程思想', '埃史尔', '机械工业出版社', 86.4, 87);
21+
insert into tb_book (title, author, publisher, price, lendcount) values ('深入理解Java虚拟机', '周志明', '机械工业出版社', 64.4, 32);
22+
insert into tb_book (title, author, publisher, price, lendcount) values ('Effective Java中文版(第2版) ', '埃史尔', '机械工业出版社', 36.8, 200);
23+
insert into tb_book (title, author, publisher, price, lendcount) values ('数据结构与算法分析:Java语言描述(原书第3版)', '马克·艾伦·维斯', '机械工业出版社', 51.0, 15);
24+
insert into tb_book (title, author, publisher, price, lendcount) values ('Java 8实战', '厄马', '人民邮电出版社', 56.8, 25);
25+
insert into tb_book (title, author, publisher, price, lendcount) values ('重构:改善既有代码的设计', '马丁·福勒', '人民邮电出版社', 53.1, 99);
26+
insert into tb_book (title, author, publisher, price, lendcount) values ('代码大全(第2版)', '史蒂夫•迈克康奈尔', '电子工业出版社', 53.1, 99);
27+
insert into tb_book (title, author, publisher, price, lendcount) values ('程序员修炼之道:从小工到专家', '亨特, 托马斯', '电子工业出版社', 45.4, 50);
28+
insert into tb_book (title, author, publisher, price, lendcount) values ('代码整洁之道', '马丁', '人民邮电出版社', 45.4, 30);
29+
insert into tb_book (title, author, publisher, price, lendcount) values ('设计模式 可复用面向对象软件的基础', 'Erich Gamma, Richard Helm', '机械工业出版社', 30.2, 77);
30+
insert into tb_book (title, author, publisher, price, lendcount) values ('设计模式之禅(第2版)', '秦小波', '机械工业出版社', 70.4, 100);
3131

Day36-40/code/shop_create_sql.sql

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
drop database if exists Shop;
2-
create database Shop default charset utf8;
3-
use Shop;
1+
drop database if exists shop;
2+
create database shop default charset utf8;
3+
4+
use shop;
5+
46
drop table if exists tb_goods;
57
create table tb_goods
68
(
@@ -10,6 +12,7 @@ gprice decimal(10,2) not null,
1012
gimage varchar(255),
1113
primary key (gid)
1214
);
15+
1316
insert into tb_goods values
1417
(default, '乐事(Lay’s)无限薯片', 8.2, 'images/lay.jpg'),
1518
(default, '旺旺 仙贝 加量装 540g', 18.5, 'images/wang.jpg'),

Day36-40/code/srs_exercise_origin.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use SRS;
2-
31
-- 查询所有学生信息
42

53
-- 查询所有课程名称及学分(投影和别名)

0 commit comments

Comments
 (0)