随笔分类 -  2.1数据库Mysql

10pymysql使用方法
摘要:1使用流程 1建立数据库连接(db=pymysql.connect(...)) 2创建游标对象(cur=db.cursor()) 3游标方法:cur.execute("insert...") 4提交到数据库或者获取数据:db.commit()/db.fetchall() 5关闭游标对象:cur.cl 阅读全文
posted @ 2020-07-06 18:50 知否知否, 阅读(190) 评论(0) 推荐(0)
9索引与查看运行时间
摘要:1创建索引 #create index 索引名 on 表名(列名) create index name_index on index_test(name); 2删除索引 #drop index 索引名 on 表名 drop index name_index on index_test; 3查看语句执 阅读全文
posted @ 2020-07-06 16:58 知否知否, 阅读(180) 评论(0) 推荐(0)
8mysql修改表-alter
摘要:#添加字段 ALTER TABLE interest ADD tel CHAR(11) AFTER price; #删除字段 ALTER TABLE interest DROP tel; #修改字段数据类型 ALTER TABLE interest MODIFY tel CHAR(16); #修改字 阅读全文
posted @ 2020-07-06 15:53 知否知否, 阅读(234) 评论(0) 推荐(0)
7mysql高级查询
摘要:CREATE DATABASE books CHARSET=utf8; USE books; CREATE TABLE book( id INT PRIMARY KEY AUTO_INCREMENT, title VARCHAR(50) NOT NULL, author VARCHAR(30) NO 阅读全文
posted @ 2020-07-06 14:32 知否知否, 阅读(127) 评论(0) 推荐(0)
6mysql外键
摘要:SHOW DATABASES; USE db1; #drop table department; CREATE TABLE department( id INT AUTO_INCREMENT PRIMARY KEY, title CHAR(15) )ENGINE=INNODB DEFAULT CHA 阅读全文
posted @ 2020-07-06 10:01 知否知否, 阅读(100) 评论(0) 推荐(0)
4mysql数据表增删改查
摘要:1增 insert into t1(id,name) values(1,'alex'); 2删 delete from t1 where id<5; #where表示条件drop table t1; 3改 update t1 set age=18; update t1 set age=18 wher 阅读全文
posted @ 2020-07-06 08:38 知否知否, 阅读(133) 评论(0) 推荐(0)
5mysql数据类型
摘要:1数字 tinyint int bigint FLOAT DOUBLE decimal 2字符串 char(10) #一点占10个字节,速度快 varchar(10) #节省空间,速度慢 最高都是255PS:把定长的往前放。textPS文件存硬盘,数据库存路径。 3时间类型 日期:DATA日期时间: 阅读全文
posted @ 2020-07-06 08:28 知否知否, 阅读(124) 评论(0) 推荐(0)
3mysql数据库操作
摘要:1创建用户 create user 'alex'@'192.168.1.1' identified by '159357'; #指定Ip create user 'alex'@'192.168.1.%' identified by '159357'; #Ip前面部分只要匹配即可 create use 阅读全文
posted @ 2020-07-05 23:50 知否知否, 阅读(149) 评论(0) 推荐(0)
2mysql基本使用
摘要:见我的csdn 阅读全文
posted @ 2020-07-05 17:02 知否知否, 阅读(63) 评论(0) 推荐(0)
1mysql安装
摘要:1百度云盘下载5.7.28,解压到E盘根目录 2在mysql-5.7.28-winx64文件夹下面新建一个my.ini文件和一个data文件夹,my.ini内容为 [mysqld] # 设置3306端口 port=3306 # 设置mysql的安装目录 basedir=E:\\mysql-5.7.2 阅读全文
posted @ 2020-07-05 16:55 知否知否, 阅读(60) 评论(0) 推荐(0)