随笔分类 -  数据库类处理

摘要:update tab1 a left join tab2 b on a.store_id=b.store_id set a.order_id=b.id where a.an<> 1 and a.an <> '' insert into tab1 (id,time) select id,time fr 阅读全文
posted @ 2025-05-12 09:24 东方素 阅读(81) 评论(0) 推荐(0)
摘要:类似 excel的日期为2021-12-28 导入mysql后变成44558 用date_add('1899-12-30', interval 44558 day) 转换成正常日期 阅读全文
posted @ 2025-04-03 11:47 东方素 阅读(19) 评论(0) 推荐(0)
摘要:1.单列索引和组合索引 一般确保索引应用在where条件中,提高查询速度 但过多会降低insert、update、delete速度 2.处理同名商户时,增加union_id(varchar32) 商户名中文,union_id英文 索引较优 3.在制作工单表上 添加基础属性字段(名、机构、状态、、), 阅读全文
posted @ 2023-03-14 16:30 东方素 阅读(21) 评论(0) 推荐(0)
摘要:1.创建视图,相对于平时使用的select语句,虚拟表 理解为存储起来的 SELECT 语句 CREATE VIEW 视图名称 AS 查询语句 CREATE view records_status_view as SELECT a.id from ims_records a LEFT JOIN im 阅读全文
posted @ 2023-03-09 15:46 东方素 阅读(27) 评论(0) 推荐(0)
摘要:最近项目在用mysql语句 指定非空,默认值为空字符串 NOT NULL DEFAULT '' 建表 CREATE TABLE IF NOT EXISTS `ims_test` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT ,`sid` int(11 阅读全文
posted @ 2020-07-27 18:51 东方素 阅读(942) 评论(0) 推荐(0)
摘要:数据字段中存放的是id集,形如 1,2,15,35 也可类推json格式 查询时不用拆分了, 用上 instr、concat搜索和连接字符串 查询fids中包含15的 select * from table where instr(concat(',', fids, ','), ',15,') > 阅读全文
posted @ 2019-03-26 09:39 东方素 阅读(228) 评论(0) 推荐(0)
摘要:mysql常用存储引擎:InnoDB、MyISAM(常用) InnoDB用于增删改操作较多,性能较优 MyISAM用于大量查询,设置索引,提高性能 1.mysql的索引优化 a.对应常查询的数字列可做索引 b.提升连表查询速度,对外键设置索引 阅读全文
posted @ 2017-09-14 18:07 东方素 阅读(271) 评论(0) 推荐(0)