随笔分类 -  mysql

mysql笔记
摘要:2. 直接mysqldump 一.MYSQL的命令行模式的设置:桌面->我的电脑->属性->环境变量->新建->PATH=“;path\mysql\bin;”其中path为MYSQL的安装路径。二.简单的介绍一下命令行进入MYSQL的方法:1.C:\>mysql -h hostname -u use 阅读全文
posted @ 2022-11-21 17:05 pengcx 阅读(120) 评论(0) 推荐(0)
摘要:下面语句会返回0 SELECT COALESCE(SUM(column),0) FROM table WHERE ... 阅读全文
posted @ 2021-07-27 18:53 pengcx 阅读(344) 评论(0) 推荐(0)
摘要:当数据库中存在,不在排序字段中的值时,数据会排在最前面 列如: 阅读全文
posted @ 2020-12-08 15:30 pengcx 阅读(535) 评论(0) 推荐(0)
摘要:1、登录: mysql -u root -p 2、查看当前有的数据库:show databases;3、创建数据库:create database 数据库名;4、操作(使用)数据库:use 数据库名;5、查看有哪些表:show tables;6、创建表:create table 表名(); 7、删除 阅读全文
posted @ 2020-01-20 15:21 pengcx 阅读(94) 评论(0) 推荐(0)
摘要:ALTER TABLE 表名 add `字段名` tinyint(1) NOT NULL DEFAULT '0' COMMENT ' ' AFTER `字段名`; 阅读全文
posted @ 2019-09-19 19:13 pengcx 阅读(1195) 评论(0) 推荐(0)
摘要:来源:https://www.cnblogs.com/yycc/p/7338894.html 阅读全文
posted @ 2019-08-21 16:34 pengcx 阅读(151) 评论(0) 推荐(0)
摘要:`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURREN 阅读全文
posted @ 2019-07-19 09:32 pengcx 阅读(1736) 评论(0) 推荐(0)
摘要:参考文档:https://github.com/zhishutech/mysql-sql-standard/blob/master/SUMMARY.md 基础规范 全部使用 InnoDB 引擎,MyISAM适用场景非常少 MyISAM与InnoDB区别 字符集:统一使用 utf8mb4 注释规范 表 阅读全文
posted @ 2019-05-31 18:58 pengcx 阅读(194) 评论(0) 推荐(0)
摘要:1、查看mysql数据库SHOW DATABASES;(;号一定要加)2、创建root用户密码mysqladmin -u root password "new_password"3、检查mysql服务器是否启动ps -ef | grep mysqld4、 添加用户方法:GRANT USAGE ON 阅读全文
posted @ 2018-08-15 14:05 pengcx 阅读(133) 评论(0) 推荐(0)
摘要:explain MySQL语句 列如 explain SELECT * FROM 表名 WHERE id=1; 阅读全文
posted @ 2018-07-19 14:14 pengcx 阅读(159) 评论(0) 推荐(0)
摘要:知识关键词:DATE_FORMAT ps:如果时间字段为时间戳则,DATE_FORMAT(from_unixtime(create_time),'%Y-%u') 根据format字符串格式化date值。下列修饰符可以被用在format字符串中: %M 月名字(January……December) % 阅读全文
posted @ 2018-02-01 15:26 pengcx 阅读(204) 评论(0) 推荐(0)
摘要:1、替换某个字段的部分内容 UPDATE tb1 SET f1=REPLACE(f1, 'abc', 'def'); 阅读全文
posted @ 2017-11-14 14:15 pengcx 阅读(120) 评论(0) 推荐(0)
摘要:将字段类型设置为utf8mb4_unicode_ci 阅读全文
posted @ 2017-09-21 14:10 pengcx 阅读(540) 评论(0) 推荐(0)
摘要:DB::query('SHOW TABLE STATUS');//读取表信息 DB::query("OPTIMIZE TABLE tableName ");//优化表 DB::query("REPAIR TABLE tableName ")//修复表 阅读全文
posted @ 2017-09-20 13:16 pengcx 阅读(247) 评论(0) 推荐(0)
摘要:如果表在创建并导入数据以后,不会在进行修改操作,那么这样的表或许适合采用MyISAM压缩表。 压缩表可以极大地减少磁盘空间暂用,因此也可以减少磁盘I/O,从而提升查询性能,压缩表也支持索引。 阅读全文
posted @ 2017-09-14 17:21 pengcx 阅读(396) 评论(0) 推荐(0)
摘要:http://www.cnblogs.com/qcloud1001/p/6555252.html 阅读全文
posted @ 2017-09-14 13:41 pengcx 阅读(102) 评论(0) 推荐(0)
摘要:http://www.imooc.com/learn/463 阅读全文
posted @ 2017-08-28 10:57 pengcx 阅读(169) 评论(0) 推荐(0)
摘要:ps:时间字段为时间戳 时间字段为datetime 阅读全文
posted @ 2017-08-21 09:32 pengcx 阅读(373) 评论(0) 推荐(0)
摘要:http://www.w3school.com.cn/sql/sql_union.asp 阅读全文
posted @ 2017-07-28 17:46 pengcx 阅读(112) 评论(0) 推荐(0)
摘要:使用group('主表.id')去重 阅读全文
posted @ 2017-07-28 15:19 pengcx 阅读(1442) 评论(0) 推荐(0)