```sql
# 優化表
optimize table <table>
# 查看表索引
show keys from <table>
# 建立索引
alter table <table> add index <index> (field(len),field2,field3)
# 刪除索引
alter table <table> drop index <index>
# 導出整個數據庫
mysqldump -u dbuser -p dbname > dbname.sql
# 導出整個數據庫結構
mysqldump -u dbuser -p -d --add-drop-table dbname > dbname.sql
# 導出數據庫表
mysqldump -u dbuser -p dbname dbtable > dbtable.sql
# 導入sql文件(進到數據庫)
use dbname
source dbname.sql
# on duplicate key update 當插入的數據導致唯一索引或主鍵出現重復值,則執行update,否則執行insert
insert into table(a,b,c) values(1,2,3) on duplicate key update d = c+1
相當于
update table set d = c + 1 where a = 1 or b =2
# 統計每天數據量
select date_format(create_date,'%Y-%m-%d') as oneday,count(*) as total from user group by oneday;
# 統計今天數據量 (to_days返回一個天數)
select count(*) as total from user where to_days(now()) = to_days(create_date)
# 統計7天數據量
select count(*) as total from user where date_sub(curdate(), interval 7 day) < date(create_date)
# 統計上一個數據量
select count(*) as total from user where period_diff(date_format(now(),'%Y-%m'), date_format(create_date, '%Y-%m')) = 1
```
- php
- 編譯安裝
- 基本概念
- 垃圾回收機制
- 生命周期
- zval底層實現
- c擴展開發
- gdb調試工具
- 自定義擴展簡單demo
- 鉤子函數
- 讀取php.ini配置
- 數組
- 函數
- 類
- yaf擴展底層源碼
- swoole擴展底層源碼
- memoryGlobal內存池
- swoole協程使用記錄
- 單點登錄sso原理
- compser使用
- session實現機制
- c & linux
- gcc
- 指針
- 結構體,聯合和位字段
- 宏定義井號說明
- printf家族函數和可變參數
- 共享函數
- 靜態庫和動態庫
- makefile自動化構建
- 信號一
- 信號二
- inotify監控文件事件
- socket編程
- 簡介
- UNIX DOMAIN
- Internet DOMAIN
- TCP/IP
- 文件IO多路復用
- 內存管理
- 進程組,會話和控制終端
- daemon守護進程
- 多進程
- 多線程
- 常用進制轉換
- go
- 入門知識
- 字節和整數裝換
- python
- redis
- 應用場景
- 消息隊列
- 熱點數據
- 掃碼登錄
- 訂閱發布
- 次數限制
- 搶購超賣
- 持久化機制
- mysql
- 工作流程
- MyISAM和InnoDB區別
- 用戶和權限管理
- 執行計劃
- sql優化
- 事務和鎖
- 慢查詢日志
- case...when...then...end用法
- sql
- 參考
- linux
- 內核參數優化
- 防火墻設置
- docker
- docker入門知識
- 算法
- 多維數組合
- DFA算法
- 紅包金額分配