博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
logging 日志表的设计
阅读量:6576 次
发布时间:2019-06-24

本文共 4129 字,大约阅读时间需要 13 分钟。

Netkiller MySQL 手札

MySQL MariaDB...

MrNeo Chan陈景峰(BG7NYT)

中国广东省深圳市龙华新区民治街道溪山美地
518131
+86 13113668890
+86 755 29812080

文档始创于2010-11-18

版权 © 2011, 2012, 2013 Netkiller(Neo Chan). All rights reserved.

版权声明

转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。

文档出处:

 

$Date: 2013-04-10 15:03:49 +0800 (Wed, 10 Apr 2013) $

我的系列文档

 

     

 


 

 

4.11. logging 日志表的设计

CREATE TABLE `logging` (	`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,	`tag` ENUM('unknow','www','user','admin') NOT NULL DEFAULT 'unknow' COMMENT '日志标签',	`time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '产生时间',	`facility` ENUM('bank','unionpay','sms','email') NOT NULL COMMENT '类别',	`priority` ENUM('info','warning','error','critical','exception','debug') NOT NULL COMMENT '级别',	`message` VARCHAR(512) NOT NULL COMMENT '内容',	PRIMARY KEY (`id`))COMMENT='日志表'COLLATE='utf8_general_ci'ENGINE=InnoDBAUTO_INCREMENT=2;

分区日志表

delimiter $$CREATE TABLE `logging` (  `tag` enum('unknow','login','info','admin','cron','manual') NOT NULL DEFAULT 'unknow' COMMENT '日志标签',  `asctime` datetime NOT NULL COMMENT '产生时间',  `facility` enum('account','bank','unionpay','sms','email','unknow') NOT NULL DEFAULT 'unknow' COMMENT '类别',  `priority` enum('info','warning','error','critical','exception','debug') NOT NULL DEFAULT 'debug' COMMENT '级别',  `message` varchar(512) NOT NULL COMMENT '内容',  `operator` varchar(50) NOT NULL DEFAULT 'computer' COMMENT '操作者') ENGINE=InnoDB DEFAULT CHARSET=utf8/*!50100 PARTITION BY RANGE (YEAR(asctime))SUBPARTITION BY HASH (MONTH(asctime))(PARTITION p0 VALUES LESS THAN (1990) ENGINE = InnoDB, PARTITION p1 VALUES LESS THAN (2000) ENGINE = InnoDB, PARTITION p2 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */$$

分表+分区,每年分表一次,每个分区中保存一个月的数据

delimiter $$CREATE TABLE `logging_2013` (  `tag` enum('unknow','login','info','admin','cron','manual') NOT NULL DEFAULT 'unknow' COMMENT '日志标签',  `asctime` datetime NOT NULL COMMENT '产生时间',  `facility` enum('account','bank','unionpay','sms','email','unknow') NOT NULL DEFAULT 'unknow' COMMENT '类别',  `priority` enum('info','warning','error','critical','exception','debug') NOT NULL DEFAULT 'debug' COMMENT '级别',  `message` varchar(512) NOT NULL COMMENT '内容',  `operator` varchar(50) NOT NULL DEFAULT 'computer' COMMENT '操作者') ENGINE=InnoDB DEFAULT CHARSET=utf8/*!50100 PARTITION BY LIST (MONTH(asctime))SUBPARTITION BY KEY (facility)(PARTITION part0 VALUES IN (1) ENGINE = InnoDB, PARTITION part1 VALUES IN (2) ENGINE = InnoDB, PARTITION part2 VALUES IN (3) ENGINE = InnoDB, PARTITION part3 VALUES IN (4) ENGINE = InnoDB, PARTITION part4 VALUES IN (5) ENGINE = InnoDB, PARTITION part5 VALUES IN (6) ENGINE = InnoDB, PARTITION part6 VALUES IN (7) ENGINE = InnoDB, PARTITION part7 VALUES IN (8) ENGINE = InnoDB, PARTITION part8 VALUES IN (9) ENGINE = InnoDB, PARTITION part9 VALUES IN (10) ENGINE = InnoDB, PARTITION part10 VALUES IN (11) ENGINE = InnoDB, PARTITION part11 VALUES IN (12) ENGINE = InnoDB) */$$

命名分区

delimiter $$CREATE TABLE `logging_2012` (  `tag` enum('unknow','login','info','admin','cron','manual') NOT NULL DEFAULT 'unknow' COMMENT '日志标签',  `asctime` datetime NOT NULL COMMENT '产生时间',  `facility` enum('account','bank','unionpay','sms','email','unknow') NOT NULL DEFAULT 'unknow' COMMENT '类别',  `priority` enum('info','warning','error','critical','exception','debug') NOT NULL DEFAULT 'debug' COMMENT '级别',  `message` varchar(512) NOT NULL COMMENT '内容',  `operator` varchar(50) NOT NULL DEFAULT 'computer' COMMENT '操作者') ENGINE=InnoDB DEFAULT CHARSET=utf8/*!50100 PARTITION BY LIST (MONTH(asctime))SUBPARTITION BY KEY (facility)(PARTITION January VALUES IN (1) ENGINE = InnoDB, PARTITION February VALUES IN (2) ENGINE = InnoDB, PARTITION March VALUES IN (3) ENGINE = InnoDB, PARTITION April VALUES IN (4) ENGINE = InnoDB, PARTITION May VALUES IN (5) ENGINE = InnoDB, PARTITION June VALUES IN (6) ENGINE = InnoDB, PARTITION July VALUES IN (7) ENGINE = InnoDB, PARTITION August VALUES IN (8) ENGINE = InnoDB, PARTITION September VALUES IN (9) ENGINE = InnoDB, PARTITION October VALUES IN (10) ENGINE = InnoDB, PARTITION November VALUES IN (11) ENGINE = InnoDB, PARTITION December VALUES IN (12) ENGINE = InnoDB) */$$

 

你可能感兴趣的文章
Python脚本日志系统
查看>>
B0BO TFS 安装指南(转载)
查看>>
gulp常用命令
查看>>
TCP(Socket基础编程)
查看>>
RowSet的使用
查看>>
每日一记--cookie
查看>>
WPF and Silverlight 学习笔记(十二):WPF Panel内容模型、Decorator内容模型及其他...
查看>>
MySQL:创建、修改和删除表
查看>>
Java多线程程序设计详细解析
查看>>
IOS 7 Study - UISegmentedControl
查看>>
八、通用类型系统
查看>>
JQuery的ajaxFileUpload的使用
查看>>
Java分享笔记:使用keySet方法获取Map集合中的元素
查看>>
Java面向对象练习题之人员信息
查看>>
关于Integer类中parseInt()和valueOf()方法的区别以及int和String类性的转换.以及String类valueOf()方法...
查看>>
ios 控制器的生命周期
查看>>
C#动态代理
查看>>
使用 sessionStorage 创建一个本地存储的 name/value
查看>>
POJ2127 LICS模板
查看>>
Python笔记8----DataFrame(二维)
查看>>