mysql的datetime设置不同的默认值,比如null和0000-00-00 00:00:00,占用字符数一样吗?

mysql的datetime设置不同的默认值,比如null和0000-00-00 00:00:00,占用字符数一样吗?

我在添加一个字段类型为datetime时,系统默认值为0000-00-00 00:00:00,是不是我将默认值改为null,会更加节省存储空间?而且查表load出数据会更快?

1个回答

首先,null 和系统给定的默认值的长度肯定是不一样的,其次,设置为null肯定更加节省空间,但是,在实际的开发中,最好不要设置成null,具体为什么不要设置为null, 可以参看:mysql中datetime类型设置默认值方法
至于查询效率的提升,跟默认值关系并不是很大,我的建议是,如果你给datetime类型设置默认值,那么设成当前时间比较好,就是连接文中的CURRENT_TIMESTAMP

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
用mybatis-plus取出mysql的datetime类型的值怎么赋给joda的Datetime
在代码中我使用了joda的datetime类,发现做查询的时候,该字段无法映射,得到Null。
请教mysql关于用户连续登陆天数的sql语句,用户在一天内可多次登陆
![图片说明](https://img-ask.csdn.net/upload/201609/11/1473569207_44549.png) 用户登录日志表,如何获取用户连续登陆的天数,用户在一天内可多次登陆;附上建表语句; CREATE TABLE `ap_user_login_logs` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `user_id` bigint(20) NOT NULL DEFAULT '0', `ip` varchar(20) NOT NULL DEFAULT '', `login_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8; /*Data for the table `ap_user_login_logs` */ insert into `ap_user_login_logs`(`id`,`user_id`,`ip`,`login_time`,`updated`,`created`) values (2,1,'','2016-09-07 19:50:16','0000-00-00 00:00:00','0000-00-00 00:00:00'),(3,1,'','2016-09-08 19:50:22','0000-00-00 00:00:00','0000-00-00 00:00:00'),(4,1,'','2016-09-09 19:50:24','0000-00-00 00:00:00','0000-00-00 00:00:00'),(5,2,'','2016-09-07 19:50:27','0000-00-00 00:00:00','0000-00-00 00:00:00'),(6,2,'','2016-09-08 19:50:31','0000-00-00 00:00:00','0000-00-00 00:00:00'),(7,2,'','2016-09-08 19:50:35','0000-00-00 00:00:00','0000-00-00 00:00:00'),(8,3,'','2016-09-08 19:52:08','0000-00-00 00:00:00','0000-00-00 00:00:00'),(9,3,'','2016-09-09 19:52:12','0000-00-00 00:00:00','0000-00-00 00:00:00'),(10,4,'','2016-09-09 19:52:21','0000-00-00 00:00:00','0000-00-00 00:00:00'),(12,1,'','2016-09-10 16:09:45','0000-00-00 00:00:00','0000-00-00 00:00:00'),(13,1,'','2016-09-10 21:09:54','0000-00-00 00:00:00','0000-00-00 00:00:00'),(14,2,'','2016-09-10 16:10:07','0000-00-00 00:00:00','0000-00-00 00:00:00'),(15,3,'','2016-09-10 16:10:16','0000-00-00 00:00:00','0000-00-00 00:00:00'),(16,4,'','2016-09-10 16:11:15','0000-00-00 00:00:00','0000-00-00 00:00:00'); /*Table structure for table `ap_user_praise` */
navicat premium 12 向 datetime数据类型的字段插入时间,为什么显示不正确?
从数据库中导出的表结构及数据,发现就是显示的不正确 ``` SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for user -- ---------------------------- DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `test` datetime(1) NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of user -- ---------------------------- INSERT INTO `user` VALUES (1, '2019-12-05 20:26:35.0'); INSERT INTO `user` VALUES (2, '1899-12-28 03:33:25.0'); INSERT INTO `user` VALUES (12, '1999-12-05 20:26:35.0'); SET FOREIGN_KEY_CHECKS = 1; ``` ![图片说明](https://img-ask.csdn.net/upload/201912/05/1575550742_688026.png)![图片说明](https://img-ask.csdn.net/upload/201912/05/1575550759_488155.png)
我在ubuntu下安装joomla的时候出的问题,请问一下为什么?
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM CHARACTER SET `utf8`' at line 29 SQL=CREATE TABLE `jos_banner` ( `bid` int(11) NOT NULL auto_increment, `cid` int(11) NOT NULL default '0', `type` varchar(30) NOT NULL default 'banner', `name` varchar(255) NOT NULL default '', `alias` varchar(255) NOT NULL default '', `imptotal` int(11) NOT NULL default '0', `impmade` int(11) NOT NULL default '0', `clicks` int(11) NOT NULL default '0', `imageurl` varchar(100) NOT NULL default '', `clickurl` varchar(200) NOT NULL default '', `date` datetime default NULL, `showBanner` tinyint(1) NOT NULL default '0', `checked_out` tinyint(1) NOT NULL default '0', `checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00', `editor` varchar(50) default NULL, `custombannercode` text, `catid` INTEGER UNSIGNED NOT NULL DEFAULT 0, `description` TEXT NOT NULL DEFAULT '', `sticky` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, `ordering` INTEGER NOT NULL DEFAULT 0, `publish_up` datetime NOT NULL default '0000-00-00 00:00:00', `publish_down` datetime NOT NULL default '0000-00-00 00:00:00', `tags` TEXT NOT NULL DEFAULT '', `params` TEXT NOT NULL DEFAULT '', PRIMARY KEY (`bid`), KEY `viewbanner` (`showBanner`), INDEX `idx_banner_catid`(`catid`) ) TYPE=MyISAM CHARACTER SET `utf8`
急,高分求答!写一段mysql脚本,查询某个部门所有员工的考勤明细和考勤状态,要完整可用的sql脚本
有四张表,分别是部门,员工,签到,时间(是否工作日),表结构如下: 部门department: ![图片说明](https://img-ask.csdn.net/upload/201901/25/1548384875_223346.png) 员工employee: ![图片说明](https://img-ask.csdn.net/upload/201901/25/1548385181_116337.png) 签到sign_record: ![图片说明](https://img-ask.csdn.net/upload/201901/25/1548385285_615335.png) 时间deal_calendar: ![图片说明](https://img-ask.csdn.net/upload/201901/25/1548385342_846878.png) 表结构和测试数据sql脚本: ``` /* Navicat MySQL Data Transfer Source Server : guangda Source Server Version : 80013 Source Host : 127.0.0.1:3306 Source Database : guangda Target Server Type : MYSQL Target Server Version : 80013 File Encoding : 65001 Date: 2019-01-25 09:08:09 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for deal_calendar -- ---------------------------- DROP TABLE IF EXISTS `deal_calendar`; CREATE TABLE `deal_calendar` ( `id` int(11) NOT NULL AUTO_INCREMENT, `date` date DEFAULT NULL COMMENT '交易日历表', `isDealDay` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'N' COMMENT '是否交易日,Y是,N不是', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of deal_calendar -- ---------------------------- INSERT INTO `deal_calendar` VALUES ('1', '2018-09-01', 'N'); INSERT INTO `deal_calendar` VALUES ('2', '2018-09-02', 'N'); INSERT INTO `deal_calendar` VALUES ('3', '2018-09-03', 'Y'); INSERT INTO `deal_calendar` VALUES ('4', '2018-09-04', 'Y'); INSERT INTO `deal_calendar` VALUES ('5', '2018-09-05', 'Y'); INSERT INTO `deal_calendar` VALUES ('6', '2018-09-06', 'Y'); INSERT INTO `deal_calendar` VALUES ('7', '2018-09-07', 'Y'); INSERT INTO `deal_calendar` VALUES ('8', '2018-09-08', 'N'); INSERT INTO `deal_calendar` VALUES ('9', '2018-09-09', 'N'); INSERT INTO `deal_calendar` VALUES ('10', '2018-09-10', 'Y'); INSERT INTO `deal_calendar` VALUES ('11', '2018-09-11', 'Y'); INSERT INTO `deal_calendar` VALUES ('12', '2018-09-12', 'Y'); INSERT INTO `deal_calendar` VALUES ('13', '2018-09-13', 'Y'); INSERT INTO `deal_calendar` VALUES ('14', '2018-09-14', 'Y'); INSERT INTO `deal_calendar` VALUES ('15', '2018-09-15', 'N'); INSERT INTO `deal_calendar` VALUES ('16', '2018-09-16', 'N'); INSERT INTO `deal_calendar` VALUES ('17', '2018-09-17', 'Y'); INSERT INTO `deal_calendar` VALUES ('18', '2018-09-18', 'Y'); INSERT INTO `deal_calendar` VALUES ('19', '2018-09-19', 'Y'); INSERT INTO `deal_calendar` VALUES ('20', '2018-09-20', 'Y'); INSERT INTO `deal_calendar` VALUES ('21', '2018-09-21', 'Y'); INSERT INTO `deal_calendar` VALUES ('22', '2018-09-22', 'N'); INSERT INTO `deal_calendar` VALUES ('23', '2018-09-23', 'N'); INSERT INTO `deal_calendar` VALUES ('24', '2018-09-24', 'Y'); INSERT INTO `deal_calendar` VALUES ('25', '2018-09-25', 'Y'); INSERT INTO `deal_calendar` VALUES ('26', '2018-09-26', 'Y'); INSERT INTO `deal_calendar` VALUES ('27', '2018-09-27', 'Y'); INSERT INTO `deal_calendar` VALUES ('28', '2018-09-28', 'Y'); INSERT INTO `deal_calendar` VALUES ('29', '2018-09-29', 'N'); INSERT INTO `deal_calendar` VALUES ('30', '2018-09-30', 'N'); -- ---------------------------- -- Table structure for department -- ---------------------------- DROP TABLE IF EXISTS `department`; CREATE TABLE `department` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '序列号', `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '部门名字', `status` int(11) DEFAULT NULL COMMENT '部门状态 0不可用,1可用', `no_permission_floors` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '无权限进入的门', PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of department -- ---------------------------- INSERT INTO `department` VALUES ('1', '固定收益部', '1', null); INSERT INTO `department` VALUES ('2', '资本市场部', '1', null); -- ---------------------------- -- Table structure for employee -- ---------------------------- DROP TABLE IF EXISTS `employee`; CREATE TABLE `employee` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '序列号', `faceId` varchar(255) DEFAULT NULL COMMENT '注册人脸库人脸id', `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '员工姓名', `empNO` varchar(64) NOT NULL COMMENT '员工编号', `cardNO` int(32) DEFAULT NULL, `postId` int(11) DEFAULT NULL COMMENT '关联岗位表id', `dept` int(11) DEFAULT NULL COMMENT '关联部门表id', `password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '员工密码', `entryTime` date DEFAULT NULL COMMENT '入职时间', `birthday` date DEFAULT NULL COMMENT '员工生日', `sex` char(1) DEFAULT NULL COMMENT '性别,M男,F女', `isblacklist` int(2) DEFAULT '0' COMMENT '是否黑名单 0不是,1是', `vip` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'N' COMMENT '是否vip,N不是,Y是', `tel` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '电话号码', `img` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '头像地址', `status` int(2) DEFAULT '1' COMMENT '0无效,1有效', `faceToken` varchar(255) DEFAULT NULL COMMENT '人脸token', `updateTime` datetime DEFAULT NULL COMMENT '更新时间', `remark` varchar(255) DEFAULT NULL COMMENT '备注,VIP客户企业', UNIQUE KEY `主索引` (`id`), UNIQUE KEY `uk_empNo` (`empNO`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of employee -- ---------------------------- INSERT INTO `employee` VALUES ('1', null, '张三', 'zhangsan', '1', null, '1', null, null, '1990-10-12', 'F', '0', 'N', null, null, '1', 'zhangsan', null, null); INSERT INTO `employee` VALUES ('2', null, '李四', 'lisi', '3', null, '1', null, null, '1982-12-16', 'M', '0', 'N', null, null, '1', 'lisi', null, null); INSERT INTO `employee` VALUES ('3', null, '王五', 'wangwu', '2', null, '2', null, null, '1990-02-01', 'M', '0', 'N', null, null, '1', 'wangwu', null, null); -- ---------------------------- -- Table structure for sign_record -- ---------------------------- DROP TABLE IF EXISTS `sign_record`; CREATE TABLE `sign_record` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '序列号', `empNO` varchar(32) DEFAULT NULL COMMENT '员工号', `confidence` float DEFAULT NULL COMMENT '比对相似度', `cardNo` varchar(32) DEFAULT NULL COMMENT '门禁卡号', `signTime` datetime DEFAULT NULL COMMENT '签到时间', `deviceNo` int(11) DEFAULT NULL COMMENT '设备号', `imagePath` varchar(255) DEFAULT NULL COMMENT '头像路径', `type` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '0' COMMENT '类型,0普通,1生日,2入职100天,3入职1000天,4,最早到,5本月全勤,6陌生人,7黑名单,8领导层', `IO` char(1) DEFAULT NULL COMMENT '进出标识', `source` int(1) DEFAULT NULL COMMENT '打卡数据来源,0人', `remark` varchar(255) DEFAULT NULL COMMENT '备注', PRIMARY KEY (`id`), UNIQUE KEY `主索引` (`id`), KEY `index_sign_time` (`signTime`) ) ENGINE=InnoDB AUTO_INCREMENT=63 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of sign_record -- ---------------------------- INSERT INTO `sign_record` VALUES ('8', 'zhangsan', null, '1', '2018-09-24 19:59:33', '512', null, '4', null, '0', ''); INSERT INTO `sign_record` VALUES ('9', 'wangwu', null, '2', '2018-09-24 20:00:26', '512', null, '0', null, '0', null); INSERT INTO `sign_record` VALUES ('24', 'lisi', null, '3', '2018-09-24 07:32:53', '512', null, '0', null, '0', null); INSERT INTO `sign_record` VALUES ('26', 'lisi', null, '3', '2018-09-24 18:53:42', '512', null, '0', null, '0', null); INSERT INTO `sign_record` VALUES ('59', 'lisi', null, '3', '2018-09-30 09:08:37', '512', null, '0', null, '0', null); INSERT INTO `sign_record` VALUES ('60', 'lisi', null, '3', '2018-09-30 18:09:16', '512', null, '0', null, '0', null); INSERT INTO `sign_record` VALUES ('61', 'kesc', null, '2', '2018-09-29 07:20:58', '512', null, '0', null, '0', null); INSERT INTO `sign_record` VALUES ('62', 'zhangsan', null, '1', '2018-09-26 12:22:01', '512', null, '0', null, '0', null); ``` 完整需求: 1.员工号,姓名,月份,工作日天数,是否全勤,正常天数,迟到天数,早退天数,迟到加早退天数,全天缺席天数 2.员工号,姓名,日期,考勤类别(正常,迟到,早退,迟到加早退,全天缺席) 补充:早上8点后迟到,下午5点半前早退,非工作日加班不用计算迟到或早退
mysql 对日期判断错误
今日测试数据:要取同一行数据中较大的日期作为有效值,但是mysql出现了判断失误的情况,直接比较大小的值是正确的,if(expr1,expr2,expr3)和case语句、greatest函数 返回的结果都有问题,将日期转化成unixtimestamp比较也是有这个问题: ## 初始化数据: SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for sorder_extend -- ---------------------------- DROP TABLE IF EXISTS `sorder_extend`; CREATE TABLE `sorder_extend` ( `sorder_id` varchar(32) NOT NULL COMMENT '主键:sorder的id', `collect_time` datetime DEFAULT NULL COMMENT '收藏时间', `add_cart_time` datetime DEFAULT NULL COMMENT '加购时间', PRIMARY KEY (`sorder_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='订单信息扩展表'; -- ---------------------------- -- Records of sorder_extend -- ---------------------------- INSERT INTO `sorder_extend` VALUES ('1905231749479YJME', '2019-05-23 18:31:41', '2019-05-23 18:21:07'); INSERT INTO `sorder_extend` VALUES ('190524112637GL6A7', '2019-05-27 16:36:59', '2019-05-27 16:37:12'); INSERT INTO `sorder_extend` VALUES ('190524113032MAYK4', '2019-05-28 19:40:05', '2019-05-29 19:40:05'); INSERT INTO `sorder_extend` VALUES ('190524113042HEUNR', '2019-05-27 16:38:53', '2019-05-27 16:39:00'); INSERT INTO `sorder_extend` VALUES ('190524113103DFPUE', null, null); INSERT INTO `sorder_extend` VALUES ('190524114012ZKSFS', '2019-05-24 11:46:33', '2019-05-24 11:55:05'); INSERT INTO `sorder_extend` VALUES ('190524115905GEHQT', '2019-05-24 11:59:39', null); INSERT INTO `sorder_extend` VALUES ('190524134532WAV2A', null, null); INSERT INTO `sorder_extend` VALUES ('190524142915HSJPZ', null, null); INSERT INTO `sorder_extend` VALUES ('190524142920LMVY4', null, null); INSERT INTO `sorder_extend` VALUES ('190524143130H79DG', null, null); INSERT INTO `sorder_extend` VALUES ('190524143146KQHQ2', null, null); INSERT INTO `sorder_extend` VALUES ('190524150522ST93R', null, null); INSERT INTO `sorder_extend` VALUES ('1905241519073GBAU', null, null); INSERT INTO `sorder_extend` VALUES ('1905241558577JFUY', null, null); INSERT INTO `sorder_extend` VALUES ('190524160245HFXRB', '2019-05-24 16:04:06', '2019-05-24 16:04:22'); INSERT INTO `sorder_extend` VALUES ('190524162015SC4NR', '2019-05-24 16:23:25', '2019-05-24 16:23:41'); INSERT INTO `sorder_extend` VALUES ('190524162329JJU6J', null, '2019-05-24 16:24:42'); INSERT INTO `sorder_extend` VALUES ('1905241625544F969', '2019-05-24 16:26:25', '2019-05-24 16:26:30'); INSERT INTO `sorder_extend` VALUES ('1905241630369M344', null, null); INSERT INTO `sorder_extend` VALUES ('190524171220LV572', null, null); INSERT INTO `sorder_extend` VALUES ('190524194425PAGBL', null, null); INSERT INTO `sorder_extend` VALUES ('1905241944578AMEM', '2019-05-24 19:45:20', '2019-05-24 19:45:25'); INSERT INTO `sorder_extend` VALUES ('190525101340737XC', '2019-05-25 10:25:22', '2019-05-25 10:34:21'); INSERT INTO `sorder_extend` VALUES ('190525101351KKYVH', null, null); INSERT INTO `sorder_extend` VALUES ('1905251036579HR7D', null, null); INSERT INTO `sorder_extend` VALUES ('190525103720WUB8A', null, null); INSERT INTO `sorder_extend` VALUES ('190525110126LAKVP', null, '2019-05-25 11:03:52'); INSERT INTO `sorder_extend` VALUES ('190525110235B8D6Y', null, null); INSERT INTO `sorder_extend` VALUES ('190525110508R4RRU', null, null); INSERT INTO `sorder_extend` VALUES ('190525110626B5GGK', '2019-05-25 11:06:40', '2019-05-25 11:06:45'); INSERT INTO `sorder_extend` VALUES ('1905251107172A8EF', null, '2019-05-25 11:20:45'); INSERT INTO `sorder_extend` VALUES ('190527161719HBJUU', '2019-05-27 16:45:27', null); INSERT INTO `sorder_extend` VALUES ('19052717554864NTC', '2019-05-27 17:56:06', '2019-05-27 18:02:32'); INSERT INTO `sorder_extend` VALUES ('190527180251V8YU6', '2019-05-27 18:03:09', '2019-05-27 18:03:14'); INSERT INTO `sorder_extend` VALUES ('190527180637VSV75', null, null); ## 查询 语句: SELECT sorder_id, add_cart_time,collect_time,IF(add_cart_time > collect_time,collect_time,add_cart_time),add_cart_time >collect_time from sorder_extend ; ## 结果展示: ![图片说明](https://img-ask.csdn.net/upload/201905/27/1558955709_928466.png)
mysql欧洲国家的文字乱码?英语、中文没有乱码是什么原因呢?
【举例】波兰语Śląskie中的Ś和ą字母显示的是? 1.修改配置文件my.ini里的: default-character-set = utf8 character-set-server = utf8 2.命令行设置: mysql> show variables like 'character%'; +--------------------------+---------------------------------------------------- -----+ | Variable_name | Value | +--------------------------+---------------------------------------------------- -----+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | C:\Program Files\MySQL\MySQL Server 5.5\share\chars ets\ | +--------------------------+---------------------------------------------------- -----+ 8 rows in set (0.05 sec) mysql> show variables like 'collation%'; +----------------------+-----------------+ | Variable_name | Value | +----------------------+-----------------+ | collation_connection | utf8_general_ci | | collation_database | utf8_general_ci | | collation_server | utf8_general_ci | +----------------------+-----------------+ 3 rows in set (0.00 sec) mysql> 3.针对我创建的数据库,设置字符集为utf8: alter database 数据库名字 character set utf8; 4.数据库表的字符集也是utf8 mysql> show create table customer_info; +---------------+--------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ------------------------------------------------------+ | Table | Create Table | +---------------+--------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ------------------------------------------------------+ | customer_info | CREATE TABLE `customer_info` ( `CUST_ID` int(11) NOT NULL DEFAULT '0', `CUST_CODE` varchar(32) NOT NULL DEFAULT '', `CUST_NAME` varchar(100) NOT NULL DEFAULT '', `CUST_CATE` char(1) DEFAULT 'N', `CURRENCY` char(3) DEFAULT 'EUR', `CONTINENT` char(1) DEFAULT 'E', `REGION` char(2) NOT NULL DEFAULT '', `PROVINCE` varchar(30) DEFAULT '', `CITY` varchar(30) DEFAULT '', `ADDRESS` varchar(150) DEFAULT '', `ZIP` varchar(10) DEFAULT '', `EMAIL` varchar(100) DEFAULT '', `WEBSITE` varchar(100) DEFAULT '', `LINKMAN` varchar(50) DEFAULT '', `PHONE` varchar(20) DEFAULT '', `FAX` varchar(20) DEFAULT '', `SP_RATE` decimal(12,5) DEFAULT '1.00000', `DATE_FORMAT` varchar(20) DEFAULT 'dd MMM, yy', `STATUS` char(1) DEFAULT 'N', `REMARKS` varchar(200) DEFAULT '', `EDITOR` varchar(32) NOT NULL DEFAULT '', `LAST_UPDATE` datetime DEFAULT NULL, `SHIP_REGION` char(2) NOT NULL DEFAULT '', `SHIP_PROVINCE` varchar(30) DEFAULT '', `SHIP_CITY` varchar(30) DEFAULT '', `SHIP_ADDRESS` varchar(150) DEFAULT '', `SHIP_ZIP` varchar(10) DEFAULT '', `TAX_ID` varchar(50) DEFAULT '', `OTHER_BRANDS` varchar(150) DEFAULT '', `COMP_TYPE` char(1) DEFAULT 'C', `SHOP_TYPE` char(1) DEFAULT 'S', `COMMENTS` text, `STORE_IMAGE` varchar(50) DEFAULT '', PRIMARY KEY (`CUST_ID`), UNIQUE KEY `CUSTOMER_INFO_CODE` (`CUST_CODE`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 | +---------------+--------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ------------------------------------------------------+ 1 row in set (0.02 sec) mysql> 5.在.jsp文件里: contentType也设置了字符集为utf8; pageEncoding也设置为utf8 [color=red][size=medium]基本上能设置的都设置了,还有什么需要设置的么?[/size][/color] ---------------- 附: 1.mysql版本是5.5 2. mysql> show character set; +----------+-----------------------------+---------------------+--------+ | Charset | Description | Default collation | Maxlen | +----------+-----------------------------+---------------------+--------+ | big5 | Big5 Traditional Chinese | big5_chinese_ci | 2 | | dec8 | DEC West European | dec8_swedish_ci | 1 | | cp850 | DOS West European | cp850_general_ci | 1 | | hp8 | HP West European | hp8_english_ci | 1 | | koi8r | KOI8-R Relcom Russian | koi8r_general_ci | 1 | | latin1 | cp1252 West European | latin1_swedish_ci | 1 | | latin2 | ISO 8859-2 Central European | latin2_general_ci | 1 | | swe7 | 7bit Swedish | swe7_swedish_ci | 1 | | ascii | US ASCII | ascii_general_ci | 1 | | ujis | EUC-JP Japanese | ujis_japanese_ci | 3 | | sjis | Shift-JIS Japanese | sjis_japanese_ci | 2 | | hebrew | ISO 8859-8 Hebrew | hebrew_general_ci | 1 | | tis620 | TIS620 Thai | tis620_thai_ci | 1 | | euckr | EUC-KR Korean | euckr_korean_ci | 2 | | koi8u | KOI8-U Ukrainian | koi8u_general_ci | 1 | | gb2312 | GB2312 Simplified Chinese | gb2312_chinese_ci | 2 | | greek | ISO 8859-7 Greek | greek_general_ci | 1 | | cp1250 | Windows Central European | cp1250_general_ci | 1 | | gbk | GBK Simplified Chinese | gbk_chinese_ci | 2 | | latin5 | ISO 8859-9 Turkish | latin5_turkish_ci | 1 | | armscii8 | ARMSCII-8 Armenian | armscii8_general_ci | 1 | | utf8 | UTF-8 Unicode | utf8_general_ci | 3 | | ucs2 | UCS-2 Unicode | ucs2_general_ci | 2 | | cp866 | DOS Russian | cp866_general_ci | 1 | | keybcs2 | DOS Kamenicky Czech-Slovak | keybcs2_general_ci | 1 | | macce | Mac Central European | macce_general_ci | 1 | | macroman | Mac West European | macroman_general_ci | 1 | | cp852 | DOS Central European | cp852_general_ci | 1 | | latin7 | ISO 8859-13 Baltic | latin7_general_ci | 1 | | utf8mb4 | UTF-8 Unicode | utf8mb4_general_ci | 4 | | cp1251 | Windows Cyrillic | cp1251_general_ci | 1 | | utf16 | UTF-16 Unicode | utf16_general_ci | 4 | | cp1256 | Windows Arabic | cp1256_general_ci | 1 | | cp1257 | Windows Baltic | cp1257_general_ci | 1 | | utf32 | UTF-32 Unicode | utf32_general_ci | 4 | | binary | Binary pseudo charset | binary | 1 | | geostd8 | GEOSTD8 Georgian | geostd8_general_ci | 1 | | cp932 | SJIS for Windows Japanese | cp932_japanese_ci | 2 | | eucjpms | UJIS for Windows Japanese | eucjpms_japanese_ci | 3 | +----------+-----------------------------+---------------------+--------+ 39 rows in set (0.00 sec) mysql> show collation -> ; +--------------------------+----------+-----+---------+----------+---------+ | Collation | Charset | Id | Default | Compiled | Sortlen | +--------------------------+----------+-----+---------+----------+---------+ | big5_chinese_ci | big5 | 1 | Yes | Yes | 1 | | big5_bin | big5 | 84 | | Yes | 1 | | dec8_swedish_ci | dec8 | 3 | Yes | Yes | 1 | | dec8_bin | dec8 | 69 | | Yes | 1 | | cp850_general_ci | cp850 | 4 | Yes | Yes | 1 | | cp850_bin | cp850 | 80 | | Yes | 1 | | hp8_english_ci | hp8 | 6 | Yes | Yes | 1 | | hp8_bin | hp8 | 72 | | Yes | 1 | | koi8r_general_ci | koi8r | 7 | Yes | Yes | 1 | | koi8r_bin | koi8r | 74 | | Yes | 1 | | latin1_german1_ci | latin1 | 5 | | Yes | 1 | | latin1_swedish_ci | latin1 | 8 | Yes | Yes | 1 | | latin1_danish_ci | latin1 | 15 | | Yes | 1 | | latin1_german2_ci | latin1 | 31 | | Yes | 2 | | latin1_bin | latin1 | 47 | | Yes | 1 | | latin1_general_ci | latin1 | 48 | | Yes | 1 | | latin1_general_cs | latin1 | 49 | | Yes | 1 | | latin1_spanish_ci | latin1 | 94 | | Yes | 1 | | latin2_czech_cs | latin2 | 2 | | Yes | 4 | | latin2_general_ci | latin2 | 9 | Yes | Yes | 1 | | latin2_hungarian_ci | latin2 | 21 | | Yes | 1 | | latin2_croatian_ci | latin2 | 27 | | Yes | 1 | | latin2_bin | latin2 | 77 | | Yes | 1 | | swe7_swedish_ci | swe7 | 10 | Yes | Yes | 1 | | swe7_bin | swe7 | 82 | | Yes | 1 | | ascii_general_ci | ascii | 11 | Yes | Yes | 1 | | ascii_bin | ascii | 65 | | Yes | 1 | | ujis_japanese_ci | ujis | 12 | Yes | Yes | 1 | | ujis_bin | ujis | 91 | | Yes | 1 | | sjis_japanese_ci | sjis | 13 | Yes | Yes | 1 | | sjis_bin | sjis | 88 | | Yes | 1 | | hebrew_general_ci | hebrew | 16 | Yes | Yes | 1 | | hebrew_bin | hebrew | 71 | | Yes | 1 | | tis620_thai_ci | tis620 | 18 | Yes | Yes | 4 | | tis620_bin | tis620 | 89 | | Yes | 1 | | euckr_korean_ci | euckr | 19 | Yes | Yes | 1 | | euckr_bin | euckr | 85 | | Yes | 1 | | koi8u_general_ci | koi8u | 22 | Yes | Yes | 1 | | koi8u_bin | koi8u | 75 | | Yes | 1 | | gb2312_chinese_ci | gb2312 | 24 | Yes | Yes | 1 | | gb2312_bin | gb2312 | 86 | | Yes | 1 | | greek_general_ci | greek | 25 | Yes | Yes | 1 | | greek_bin | greek | 70 | | Yes | 1 | | cp1250_general_ci | cp1250 | 26 | Yes | Yes | 1 | | cp1250_czech_cs | cp1250 | 34 | | Yes | 2 | | cp1250_croatian_ci | cp1250 | 44 | | Yes | 1 | | cp1250_bin | cp1250 | 66 | | Yes | 1 | | cp1250_polish_ci | cp1250 | 99 | | Yes | 1 | | gbk_chinese_ci | gbk | 28 | Yes | Yes | 1 | | gbk_bin | gbk | 87 | | Yes | 1 | | latin5_turkish_ci | latin5 | 30 | Yes | Yes | 1 | | latin5_bin | latin5 | 78 | | Yes | 1 | | armscii8_general_ci | armscii8 | 32 | Yes | Yes | 1 | | armscii8_bin | armscii8 | 64 | | Yes | 1 | | utf8_general_ci | utf8 | 33 | Yes | Yes | 1 | | utf8_bin | utf8 | 83 | | Yes | 1 | | utf8_unicode_ci | utf8 | 192 | | Yes | 8 | | utf8_icelandic_ci | utf8 | 193 | | Yes | 8 | | utf8_latvian_ci | utf8 | 194 | | Yes | 8 | | utf8_romanian_ci | utf8 | 195 | | Yes | 8 | | utf8_slovenian_ci | utf8 | 196 | | Yes | 8 | | utf8_polish_ci | utf8 | 197 | | Yes | 8 | | utf8_estonian_ci | utf8 | 198 | | Yes | 8 | | utf8_spanish_ci | utf8 | 199 | | Yes | 8 | | utf8_swedish_ci | utf8 | 200 | | Yes | 8 | | utf8_turkish_ci | utf8 | 201 | | Yes | 8 | | utf8_czech_ci | utf8 | 202 | | Yes | 8 | | utf8_danish_ci | utf8 | 203 | | Yes | 8 | | utf8_lithuanian_ci | utf8 | 204 | | Yes | 8 | | utf8_slovak_ci | utf8 | 205 | | Yes | 8 | | utf8_spanish2_ci | utf8 | 206 | | Yes | 8 | | utf8_roman_ci | utf8 | 207 | | Yes | 8 | | utf8_persian_ci | utf8 | 208 | | Yes | 8 | | utf8_esperanto_ci | utf8 | 209 | | Yes | 8 | | utf8_hungarian_ci | utf8 | 210 | | Yes | 8 | | utf8_sinhala_ci | utf8 | 211 | | Yes | 8 | | utf8_general_mysql500_ci | utf8 | 223 | | Yes | 1 | | ucs2_general_ci | ucs2 | 35 | Yes | Yes | 1 | | ucs2_bin | ucs2 | 90 | | Yes | 1 | | ucs2_unicode_ci | ucs2 | 128 | | Yes | 8 | | ucs2_icelandic_ci | ucs2 | 129 | | Yes | 8 | | ucs2_latvian_ci | ucs2 | 130 | | Yes | 8 | | ucs2_romanian_ci | ucs2 | 131 | | Yes | 8 | | ucs2_slovenian_ci | ucs2 | 132 | | Yes | 8 | | ucs2_polish_ci | ucs2 | 133 | | Yes | 8 | | ucs2_estonian_ci | ucs2 | 134 | | Yes | 8 | | ucs2_spanish_ci | ucs2 | 135 | | Yes | 8 | | ucs2_swedish_ci | ucs2 | 136 | | Yes | 8 | | ucs2_turkish_ci | ucs2 | 137 | | Yes | 8 | | ucs2_czech_ci | ucs2 | 138 | | Yes | 8 | | ucs2_danish_ci | ucs2 | 139 | | Yes | 8 | | ucs2_lithuanian_ci | ucs2 | 140 | | Yes | 8 | | ucs2_slovak_ci | ucs2 | 141 | | Yes | 8 | | ucs2_spanish2_ci | ucs2 | 142 | | Yes | 8 | | ucs2_roman_ci | ucs2 | 143 | | Yes | 8 | | ucs2_persian_ci | ucs2 | 144 | | Yes | 8 | | ucs2_esperanto_ci | ucs2 | 145 | | Yes | 8 | | ucs2_hungarian_ci | ucs2 | 146 | | Yes | 8 | | ucs2_sinhala_ci | ucs2 | 147 | | Yes | 8 | | ucs2_general_mysql500_ci | ucs2 | 159 | | Yes | 1 | | cp866_general_ci | cp866 | 36 | Yes | Yes | 1 | | cp866_bin | cp866 | 68 | | Yes | 1 | | keybcs2_general_ci | keybcs2 | 37 | Yes | Yes | 1 | | keybcs2_bin | keybcs2 | 73 | | Yes | 1 | | macce_general_ci | macce | 38 | Yes | Yes | 1 | | macce_bin | macce | 43 | | Yes | 1 | | macroman_general_ci | macroman | 39 | Yes | Yes | 1 | | macroman_bin | macroman | 53 | | Yes | 1 | | cp852_general_ci | cp852 | 40 | Yes | Yes | 1 | | cp852_bin | cp852 | 81 | | Yes | 1 | | latin7_estonian_cs | latin7 | 20 | | Yes | 1 | | latin7_general_ci | latin7 | 41 | Yes | Yes | 1 | | latin7_general_cs | latin7 | 42 | | Yes | 1 | | latin7_bin | latin7 | 79 | | Yes | 1 | | utf8mb4_general_ci | utf8mb4 | 45 | Yes | Yes | 1 | | utf8mb4_bin | utf8mb4 | 46 | | Yes | 1 | | utf8mb4_unicode_ci | utf8mb4 | 224 | | Yes | 8 | | utf8mb4_icelandic_ci | utf8mb4 | 225 | | Yes | 8 | | utf8mb4_latvian_ci | utf8mb4 | 226 | | Yes | 8 | | utf8mb4_romanian_ci | utf8mb4 | 227 | | Yes | 8 | | utf8mb4_slovenian_ci | utf8mb4 | 228 | | Yes | 8 | | utf8mb4_polish_ci | utf8mb4 | 229 | | Yes | 8 | | utf8mb4_estonian_ci | utf8mb4 | 230 | | Yes | 8 | | utf8mb4_spanish_ci | utf8mb4 | 231 | | Yes | 8 | | utf8mb4_swedish_ci | utf8mb4 | 232 | | Yes | 8 | | utf8mb4_turkish_ci | utf8mb4 | 233 | | Yes | 8 | | utf8mb4_czech_ci | utf8mb4 | 234 | | Yes | 8 | | utf8mb4_danish_ci | utf8mb4 | 235 | | Yes | 8 | | utf8mb4_lithuanian_ci | utf8mb4 | 236 | | Yes | 8 | | utf8mb4_slovak_ci | utf8mb4 | 237 | | Yes | 8 | | utf8mb4_spanish2_ci | utf8mb4 | 238 | | Yes | 8 | | utf8mb4_roman_ci | utf8mb4 | 239 | | Yes | 8 | | utf8mb4_persian_ci | utf8mb4 | 240 | | Yes | 8 | | utf8mb4_esperanto_ci | utf8mb4 | 241 | | Yes | 8 | | utf8mb4_hungarian_ci | utf8mb4 | 242 | | Yes | 8 | | utf8mb4_sinhala_ci | utf8mb4 | 243 | | Yes | 8 | | cp1251_bulgarian_ci | cp1251 | 14 | | Yes | 1 | | cp1251_ukrainian_ci | cp1251 | 23 | | Yes | 1 | | cp1251_bin | cp1251 | 50 | | Yes | 1 | | cp1251_general_ci | cp1251 | 51 | Yes | Yes | 1 | | cp1251_general_cs | cp1251 | 52 | | Yes | 1 | | utf16_general_ci | utf16 | 54 | Yes | Yes | 1 | | utf16_bin | utf16 | 55 | | Yes | 1 | | utf16_unicode_ci | utf16 | 101 | | Yes | 8 | | utf16_icelandic_ci | utf16 | 102 | | Yes | 8 | | utf16_latvian_ci | utf16 | 103 | | Yes | 8 | | utf16_romanian_ci | utf16 | 104 | | Yes | 8 | | utf16_slovenian_ci | utf16 | 105 | | Yes | 8 | | utf16_polish_ci | utf16 | 106 | | Yes | 8 | | utf16_estonian_ci | utf16 | 107 | | Yes | 8 | | utf16_spanish_ci | utf16 | 108 | | Yes | 8 | | utf16_swedish_ci | utf16 | 109 | | Yes | 8 | | utf16_turkish_ci | utf16 | 110 | | Yes | 8 | | utf16_czech_ci | utf16 | 111 | | Yes | 8 | | utf16_danish_ci | utf16 | 112 | | Yes | 8 | | utf16_lithuanian_ci | utf16 | 113 | | Yes | 8 | | utf16_slovak_ci | utf16 | 114 | | Yes | 8 | | utf16_spanish2_ci | utf16 | 115 | | Yes | 8 | | utf16_roman_ci | utf16 | 116 | | Yes | 8 | | utf16_persian_ci | utf16 | 117 | | Yes | 8 | | utf16_esperanto_ci | utf16 | 118 | | Yes | 8 | | utf16_hungarian_ci | utf16 | 119 | | Yes | 8 | | utf16_sinhala_ci | utf16 | 120 | | Yes | 8 | | cp1256_general_ci | cp1256 | 57 | Yes | Yes | 1 | | cp1256_bin | cp1256 | 67 | | Yes | 1 | | cp1257_lithuanian_ci | cp1257 | 29 | | Yes | 1 | | cp1257_bin | cp1257 | 58 | | Yes | 1 | | cp1257_general_ci | cp1257 | 59 | Yes | Yes | 1 | | utf32_general_ci | utf32 | 60 | Yes | Yes | 1 | | utf32_bin | utf32 | 61 | | Yes | 1 | | utf32_unicode_ci | utf32 | 160 | | Yes | 8 | | utf32_icelandic_ci | utf32 | 161 | | Yes | 8 | | utf32_latvian_ci | utf32 | 162 | | Yes | 8 | | utf32_romanian_ci | utf32 | 163 | | Yes | 8 | | utf32_slovenian_ci | utf32 | 164 | | Yes | 8 | | utf32_polish_ci | utf32 | 165 | | Yes | 8 | | utf32_estonian_ci | utf32 | 166 | | Yes | 8 | | utf32_spanish_ci | utf32 | 167 | | Yes | 8 | | utf32_swedish_ci | utf32 | 168 | | Yes | 8 | | utf32_turkish_ci | utf32 | 169 | | Yes | 8 | | utf32_czech_ci | utf32 | 170 | | Yes | 8 | | utf32_danish_ci | utf32 | 171 | | Yes | 8 | | utf32_lithuanian_ci | utf32 | 172 | | Yes | 8 | | utf32_slovak_ci | utf32 | 173 | | Yes | 8 | | utf32_spanish2_ci | utf32 | 174 | | Yes | 8 | | utf32_roman_ci | utf32 | 175 | | Yes | 8 | | utf32_persian_ci | utf32 | 176 | | Yes | 8 | | utf32_esperanto_ci | utf32 | 177 | | Yes | 8 | | utf32_hungarian_ci | utf32 | 178 | | Yes | 8 | | utf32_sinhala_ci | utf32 | 179 | | Yes | 8 | | binary | binary | 63 | Yes | Yes | 1 | | geostd8_general_ci | geostd8 | 92 | Yes | Yes | 1 | | geostd8_bin | geostd8 | 93 | | Yes | 1 | | cp932_japanese_ci | cp932 | 95 | Yes | Yes | 1 | | cp932_bin | cp932 | 96 | | Yes | 1 | | eucjpms_japanese_ci | eucjpms | 97 | Yes | Yes | 1 | | eucjpms_bin | eucjpms | 98 | | Yes | 1 | +--------------------------+----------+-----+---------+----------+---------+ 197 rows in set (0.00 sec)
hibernate Timstamp映射mysql中类型为什么是datetime?
hibernate为什么我设置的类型是java.sql.Timstamp但是映射到mysql数据库表中的时候类型却是datetime呢?求解~ 我知道使用@Column(columnDefinition = "timestamp")可以解决问题,但是columnDefinition属性的会破坏移植性,故求其他的解决思路。 column注解如下: ``` @Column(name = "register_time", insertable = false, updatable = false, nullable = false) public java.sql.Timestamp getRegister_time() { return register_time; } public void setRegister_time(java.sql.Timestamp register_time) { this.register_time = register_time; } ``` 生成sql如下: create table User ( id varchar(255) not null, mobilephone_number varchar(11) not null, password varchar(20) not null, register_time datetime, telephone_number varchar(12), username varchar(20) not null, primary key (id) ) hibernate数据类型映射官方文档 http://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#basic
mysql创建表,默认系统当前时间
CREATE TABLE `tmp_webservice_sql_log` ( `ID` INT(10) NOT NULL AUTO_INCREMENT, `SEND_DATA_TIME` DATETIME DEFAULT NULL, `SEND_STATE` VARCHAR(10) DEFAULT NULL, `INTER_NAME` VARCHAR(100) NOT NULL, `CREATE_TIME` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `QUERY_SQL` TEXT, `SEND_JSON` LONGTEXT, `RETURN_JSON` VARCHAR(2000) DEFAULT NULL, `SYS` TINYINT(2) DEFAULT NULL, PRIMARY KEY (`ID`,`INTER_NAME`,`CREATE_TIME`) ) ENGINE=INNODB AUTO_INCREMENT=343 DEFAULT CHARSET=utf8 create_time 字段和 QUERY_SQL字段SEND_JSON字段 报错
MySQL数据库运行从数据库中导出的sql报错,怎么回事
我的sql SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for tb_item_cat -- ---------------------------- DROP TABLE IF EXISTS `tb_item_cat`; CREATE TABLE `tb_item_cat` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '类目ID', `parent_id` bigint(20) DEFAULT NULL COMMENT '父类目ID=0时,代表的是一级的类目', `name` varchar(50) DEFAULT NULL COMMENT '类目名称', `status` int(1) DEFAULT '1' COMMENT '状态。可选值:1(正常),2(删除)', `sort_order` int(4) DEFAULT NULL COMMENT '排列序号,表示同级类目的展现次序,如数值相等则按名称次序排列。取值范围:大于零的整数', `is_parent` tinyint(1) DEFAULT '1' COMMENT '该类目是否为父类目,1为true,0为false', `created` datetime DEFAULT NULL COMMENT '创建时间', `updated` datetime DEFAULT NULL COMMENT '创建时间', PRIMARY KEY (`id`), KEY `parent_id` (`parent_id`,`status`) USING BTREE , KEY `sort_order` (`sort_order`) ) ENGINE=InnoDB AUTO_INCREMENT=1183 DEFAULT CHARSET=utf8 COMMENT='商品类目'; 报的错: [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE , KEY `sort_order` (`[sort_order]`) ) ENGINE=InnoDB AUTO_INCREM' at line 11
MySQL RC隔离级别 单表更新导致的死锁
数据库版本:阿里云RDS 5.7 隔离级别:RC 表结构:`t` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `a` datetime, `b` bigint(20), `c` varchar(255), `d` bigint(20), `e` varchar(50), `f` int(11), PRIMARY KEY (`id`) ); 产生死锁的业务代码(仅贴出伪代码): @Transactional public void update(String s) { for (int i = 1; i < 6; i++) { update t set ... where e = #{s} and f = #{i}; } } 该事务在并发场景下发生死锁,求大神解释一下为什么会死锁?
mysql如何实现两行记录相减
需求是需要统计某只股票的某个时间段的区间涨幅,表结构如下: ``` CREATE TABLE `money` ( `id` int(11) NOT NULL, `code` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL, `name` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL, `pchange` double NOT NULL, `inflow` double NOT NULL, `amount` bigint(11) NOT NULL, `price` double NOT NULL, `high` double NOT NULL, `low` double NOT NULL, `open` double NOT NULL COMMENT '开盘', `yclose` double NOT NULL COMMENT '收盘', `amplitude` double NOT NULL COMMENT '振幅', `dchratio` double NOT NULL COMMENT '换手率', `datetime` int(11) NOT NULL, `type` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ``` 我的思路是先找出时间段的数据(order by datetime),然后通过(最后一条记录的price - 首条记录的price)/ 首条记录的price *100 但不知道怎么实现,希望有人能提供 一个方法。 当然,有更好的思路就更好了,我也担心性能有问题
mysql先排序再分组再排序
原数据:![图片说明](https://img-ask.csdn.net/upload/201708/24/1503548410_950534.png) 想要的结果: y 10-01 y 08-10 y 08-07 r 09-01 r 08-25 r 08-07 ss 08-18 ss 08-07 先对他们按时间排序,再分组,再对组内的数据按时间进行排序 建表语句: DROP TABLE IF EXISTS `testor`; CREATE TABLE `testor` ( `id` int(11) NOT NULL, `name` varchar(255) DEFAULT NULL, `crdate` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of testor -- ---------------------------- INSERT INTO `testor` VALUES ('0', 'ss', '2017-08-18 09:07:42'); INSERT INTO `testor` VALUES ('1', 'y', '2017-08-10 09:07:57'); INSERT INTO `testor` VALUES ('2', 'r', '2017-08-07 09:08:06'); INSERT INTO `testor` VALUES ('3', 'r', '2017-08-25 09:08:19'); INSERT INTO `testor` VALUES ('4', 'r', '2017-09-01 09:08:33'); INSERT INTO `testor` VALUES ('5', 'ss', '2017-08-07 09:08:53'); INSERT INTO `testor` VALUES ('6', 'y', '2017-08-07 11:51:12'); INSERT INTO `testor` VALUES ('7', 'y', '2017-10-01 11:51:23');
mysql的一个奇怪问题
引擎是MyISAM,当需要扫描的行数大于等于15的时候,它就不使用索引而是全表扫描 <br /> <br />mysql&gt; desc customer; <br />+------------+---------------+------+-----+---------+----------------+ <br />| Field&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Null | Key | Default | Extra&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />+------------+---------------+------+-----+---------+----------------+ <br />| id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | bigint(20)&nbsp;&nbsp;&nbsp; | NO&nbsp;&nbsp; | PRI | NULL&nbsp;&nbsp;&nbsp; | auto_increment | <br />| name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | varchar(255)&nbsp; | NO&nbsp;&nbsp; | UNI | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />| address&nbsp;&nbsp;&nbsp; | varchar(255)&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />| linkman&nbsp;&nbsp;&nbsp; | varchar(255)&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />| mobile&nbsp;&nbsp;&nbsp;&nbsp; | varchar(255)&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />| phone&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | varchar(255)&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />| fax&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | varchar(255)&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />| memo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | varchar(2500) | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />| createDate | datetime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />+------------+---------------+------+-----+---------+----------------+ <br /> <br />mysql&gt; show index from customer \G <br />*************************** 1. row *************************** <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Table: customer <br />&nbsp; Non_unique: 0 <br />&nbsp;&nbsp;&nbsp; Key_name: PRIMARY <br />Seq_in_index: 1 <br /> Column_name: id <br />&nbsp;&nbsp; Collation: A <br /> Cardinality: 841 <br />&nbsp;&nbsp;&nbsp; Sub_part: NULL <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Packed: NULL <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Null: <br />&nbsp; Index_type: BTREE <br />&nbsp;&nbsp;&nbsp;&nbsp; Comment: <br />*************************** 2. row *************************** <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Table: customer <br />&nbsp; Non_unique: 0 <br />&nbsp;&nbsp;&nbsp; Key_name: name <br />Seq_in_index: 1 <br /> Column_name: name <br />&nbsp;&nbsp; Collation: A <br /> Cardinality: 841 <br />&nbsp;&nbsp;&nbsp; Sub_part: NULL <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Packed: NULL <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Null: <br />&nbsp; Index_type: BTREE <br />&nbsp;&nbsp;&nbsp;&nbsp; Comment: <br /> <br />mysql&gt; explain select * from customer order by id limit 15; <br />+----+-------------+----------+------+---------------+------+---------+------+------+----------------+ <br />| id | select_type | table&nbsp;&nbsp;&nbsp; | type | possible_keys | key&nbsp; | key_len | ref&nbsp; | rows | Extra&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />+----+-------------+----------+------+---------------+------+---------+------+------+----------------+ <br />|&nbsp; 1 | SIMPLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | customer | ALL&nbsp; | NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | NULL | NULL&nbsp;&nbsp;&nbsp; | NULL |&nbsp; 841 | Using filesort | <br />+----+-------------+----------+------+---------------+------+---------+------+------+----------------+ <br /> <br />mysql&gt; explain select * from customer order by id limit 14; <br />+----+-------------+----------+-------+---------------+---------+---------+------+------+-------+ <br />| id | select_type | table&nbsp;&nbsp;&nbsp; | type&nbsp; | possible_keys | key&nbsp;&nbsp;&nbsp;&nbsp; | key_len | ref&nbsp; | rows | Extra | <br />+----+-------------+----------+-------+---------------+---------+---------+------+------+-------+ <br />|&nbsp; 1 | SIMPLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | customer | index | NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | PRIMARY | 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | NULL |&nbsp;&nbsp; 14 |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />+----+-------------+----------+-------+---------------+---------+---------+------+------+-------+ <br /> <br />mysql&gt; explain select * from customer order by id limit 7,8; <br />+----+-------------+----------+------+---------------+------+---------+------+------+----------------+ <br />| id | select_type | table&nbsp;&nbsp;&nbsp; | type | possible_keys | key&nbsp; | key_len | ref&nbsp; | rows | Extra&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />+----+-------------+----------+------+---------------+------+---------+------+------+----------------+ <br />|&nbsp; 1 | SIMPLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | customer | ALL&nbsp; | NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | NULL | NULL&nbsp;&nbsp;&nbsp; | NULL |&nbsp; 841 | Using filesort | <br />+----+-------------+----------+------+---------------+------+---------+------+------+----------------+ <br /> <br />mysql&gt; explain select * from customer order by id limit 7,7; <br />+----+-------------+----------+-------+---------------+---------+---------+------+------+-------+ <br />| id | select_type | table&nbsp;&nbsp;&nbsp; | type&nbsp; | possible_keys | key&nbsp;&nbsp;&nbsp;&nbsp; | key_len | ref&nbsp; | rows | Extra | <br />+----+-------------+----------+-------+---------------+---------+---------+------+------+-------+ <br />|&nbsp; 1 | SIMPLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | customer | index | NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | PRIMARY | 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | NULL |&nbsp;&nbsp; 14 |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | <br />+----+-------------+----------+-------+---------------+---------+---------+------+------+-------+ <br />
mysql的创建表的语句后面有auto_increment=4
``` CREATE TABLE `easybuy_order` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', `userId` int(255) DEFAULT NULL COMMENT '用户主键', `loginName` varchar(255) DEFAULT NULL, `userAddress` varchar(255) DEFAULT NULL COMMENT '用户地址', `createTime` datetime DEFAULT NULL COMMENT '创建时间', `cost` float DEFAULT NULL COMMENT '总消费', `serialNumber` varchar(255) DEFAULT NULL COMMENT '订单号', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; ``` 后面的AUTO_INCREMENT=4是啥意思?
Mysql插入时出现未知列错误
在添加记录时程序提示“添加失败”,用debug跟了代码发现在向MySQL插入数据时出的错。后来打开mysql,单独执行该语句仍然出错。以下是具体情况: sql语句是: Insert INTO testTbl (ID) Values (586) 表结构是: mysql> desc testTbl; +------------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------+---------------+------+-----+---------+-------+ | ID | int(10) | NO | | 0 | | | Comp_Totalsect | varchar(10) | YES | | NULL | | | Comp_Sort | varchar(20) | YES | | NULL | | | Comp_Category | varchar(40) | YES | | NULL | | | Comp_Content | varchar(8) | YES | | NULL | | | Comp_Vol | int(10) | YES | | NULL | | | ArchNo | varchar(80) | YES | | NULL | | | Archive_Name | varchar(400) | YES | | NULL | | | Secret_Level | varchar(10) | YES | | NULL | | | Storage_Life | varchar(10) | YES | | NULL | | | FileYear | smallint(4) | YES | | NULL | | | Archive_Unit | varchar(50) | YES | | NULL | | | Storage_Unit | varchar(50) | YES | | NULL | | | LeiMu | varchar(20) | YES | | NULL | | | Keywords | varchar(255) | YES | | NULL | | | Importer | varchar(20) | YES | | NULL | | | CreateDate | datetime | YES | | NULL | | | CheckMan | varchar(20) | YES | | NULL | | | Hua_Kong | varchar(10) | YES | | NULL | | | Page_Num | int(10) | YES | | NULL | | | Register_Unit | varchar(50) | YES | | NULL | | | Can_Brrw | int(5) | NO | | 1 | | | Can_BrrwCopies | int(5) | YES | | 1 | | | CanCopies | int(5) | YES | | 1 | | | StatusBT | smallint(2) | YES | | 0 | | | HandOverStatus | smallint(1) | YES | | 0 | | | Del_Tag | smallint(1) | YES | | 0 | | | FullTextFile | int(10) | YES | | NULL | | | FileNo | int(10) | YES | | NULL | | | WenHao | varchar(2000) | YES | | NULL | | | File_Date | datetime | YES | | NULL | | | Principal | varchar(2000) | YES | | NULL | | | Total_Vol | int(10) | YES | | NULL | | | Memo | varchar(2000) | YES | | NULL | | | AboutInfo | varchar(3000) | YES | | NULL | | | Old_Organization | varchar(1000) | YES | | NULL | | | Judge | varchar(500) | YES | | NULL | | | EndYear | varchar(20) | YES | | NULL | | | Old_ArchNo | varchar(200) | YES | | NULL | | | Old_Comp_Content | varchar(200) | YES | | NULL | | | Old_Comp_Sort | varchar(200) | YES | | NULL | | | Old_Comp_Vol | varchar(200) | YES | | NULL | | | KeepYear | smallint(4) | YES | | 1000 | | +------------------+---------------+------+-----+---------+-------+ 43 rows in set (0.02 sec) [b][color=red]mysql> Insert INTO testTbl (ID) Values (586); ERROR 1054 (42S22): Unknown column 'FileNo' in 'field list'[/color][/b] 这就奇怪了,我只插入一个id而已,怎么会说到FileNo,而且表里面也有那一列啊,反复看就是发现不了错误,发上来看各位能否看出一些端倪,在此谢过~
Cannot add foreign key constraint,MySQL无法建立外键
已经确保1、字段的数据类型或者数据长度一样 2、外键是其他表的主键 求助!! **需要建立外键的表play,代码如下** ``` -- 建play表 CREATE TABLE play ( playID INT(2) UNSIGNED NOT NULL AUTO_INCREMENT, playerID INT(8), gameID INT(1), PRIMARY KEY (playID), -- 外键约束 FOREIGN KEY (playerID) REFERENCES players(playerID), FOREIGN KEY (gameID) REFERENCES game(gameID) ); ``` **两个外键涉及到的表,①players表如下** ``` -- 建players表 CREATE TABLE players( playerID INT(8) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT, -- 空值约束 playerName VARCHAR(20) NOT NULL, -- 控制约束 playerNumber INT(2) NOT NULL, -- 唯一约束 playerSize VARCHAR(5) DEFAULT 'M', playerPosition VARCHAR(20), isSarting ENUM('Y','N'), PRIMARY KEY (playerID) -- 主键约束 ) ENGINE = MYISAM AUTO_INCREMENT = 15071019 DEFAULT CHARSET = utf8; ``` **②game表如下** ``` -- 建game表 CREATE TABLE game( gameID INT(1), gameDate DATETIME, gameLocation VARCHAR(20), opponent VARCHAR(20), PRIMARY KEY (gameID) ) ENGINE = MYISAM AUTO_INCREMENT = 5 DEFAULT CHARSET = utf8; ```
mysql错误代码 Err] 1215
运行生气了语句: CREATE TABLE `net_ippoolexludesection` ( `sectionId` int(11) NOT NULL AUTO_INCREMENT, `ippoolId` int(11) NOT NULL COMMENT '地址池ID', `routeId` int(11) NOT NULL COMMENT '设备ID', `startip` varchar(15) NOT NULL COMMENT '起始地址', `endip` varchar(15) NOT NULL COMMENT '结束地址', `lstartip` bigint(255) NOT NULL COMMENT '其实IP', `lendip` bigint(255) NOT NULL COMMENT '结束IP', PRIMARY KEY (`sectionId`), CONSTRAINT `net_ippoolexludesection_ibfk_1` FOREIGN KEY (`ippoolId`) REFERENCES `net_ippoolinfo` (`poolid`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ip地址池排除地址段'; 报错 Err] 1215 - Cannot add foreign key constraint net_ippoolinfo 表的结构如下 CREATE TABLE `net_ippoolinfo` ( `poolid` int(7) NOT NULL AUTO_INCREMENT, `poolName` varchar(50) NOT NULL, `routid` int(11) NOT NULL, `gateway` varchar(15) DEFAULT NULL, `maskStr` varchar(15) DEFAULT NULL, `dnsip` varchar(50) DEFAULT NULL, `poolSection` varchar(200) DEFAULT NULL, `vpnName` varchar(50) DEFAULT NULL, `maxUseNum` int(7) DEFAULT NULL, `produceTime` datetime DEFAULT NULL, `poolDomain` varchar(255) DEFAULT NULL, `poolDomain1` varchar(255) DEFAULT NULL, PRIMARY KEY (`poolid`), UNIQUE KEY `dd` (`poolid`) ) ENGINE=InnoDB AUTO_INCREMENT=220 DEFAULT CHARSET=utf8; mysql 版本 5.6 就大神指教,
mysql分表问题(insert_method的理解)
CREATE TABLE `account_all` ( `id` int(11) NOT NULL AUTO_INCREMENT , `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL , `money` float NOT NULL , `tradeDate` datetime NOT NULL PRIMARY KEY (`id`) ) ENGINE=MRG_MYISAM DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci UNION=(`account_2011`,`account_2012`) INSERT_METHOD=LAST ROW_FORMAT=DYNAMIC; insert_method=last,那是不是将来所有的操作都放到了account_2012中呢,数据量大了不是account_2012会很大,这也没有什么意义啊。实际中是怎么处理呢。
相见恨晚的超实用网站
相见恨晚的超实用网站 持续更新中。。。
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载 点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。 ...
字节跳动视频编解码面经
三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时想着能进去就不错了,管他哪个岗呢,就同意了面试...
开源一个功能完整的SpringBoot项目框架
福利来了,给大家带来一个福利。 最近想了解一下有关Spring Boot的开源项目,看了很多开源的框架,大多是一些demo或者是一个未成形的项目,基本功能都不完整,尤其是用户权限和菜单方面几乎没有完整的。 想到我之前做的框架,里面通用模块有:用户模块,权限模块,菜单模块,功能模块也齐全了,每一个功能都是完整的。 打算把这个框架分享出来,供大家使用和学习。 为什么用框架? 框架可以学习整体...
源码阅读(19):Java中主要的Map结构——HashMap容器(下1)
HashMap容器从字面的理解就是,基于Hash算法构造的Map容器。从数据结构的知识体系来说,HashMap容器是散列表在Java中的具体表达(并非线性表结构)。具体来说就是,利用K-V键值对中键对象的某个属性(默认使用该对象的“内存起始位置”这一属性)作为计算依据进行哈希计算(调用hashCode方法),然后再以计算后的返回值为依据,将当前K-V键值对在符合HashMap容器构造原则的基础上,放置到HashMap容器的某个位置上,且这个位置和之前添加的K-V键值对的存储位置完全独立,不一定构成连续的存储
c++制作的植物大战僵尸,开源,一代二代结合游戏
此游戏全部由本人自己制作完成。游戏大部分的素材来源于原版游戏素材,少部分搜集于网络,以及自己制作。 此游戏为同人游戏而且仅供学习交流使用,任何人未经授权,不得对本游戏进行更改、盗用等,否则后果自负。目前有六种僵尸和六种植物,植物和僵尸的动画都是本人做的。qq:2117610943 开源代码下载 提取码:3vzm 点击下载--&gt; 11月28日 新增四种植物 统一植物画风,全部修...
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
Python——画一棵漂亮的樱花树(不同种樱花+玫瑰+圣诞树喔)
最近翻到一篇知乎,上面有不少用Python(大多是turtle库)绘制的树图,感觉很漂亮,我整理了一下,挑了一些我觉得不错的代码分享给大家(这些我都测试过,确实可以生成) one 樱花树 动态生成樱花 效果图(这个是动态的): 实现代码 import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, ...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
Python 基础(一):入门必备知识
Python 入门必备知识,你都掌握了吗?
深度学习图像算法在内容安全领域的应用
互联网给人们生活带来便利的同时也隐含了大量不良信息,防范互联网平台有害内容传播引起了多方面的高度关注。本次演讲从技术层面分享网易易盾在内容安全领域的算法实践经验,包括深度...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
经典算法(5)杨辉三角
写在前面: 我是 扬帆向海,这个昵称来源于我的名字以及女朋友的名字。我热爱技术、热爱开源、热爱编程。技术是开源的、知识是共享的。 这博客是对自己学习的一点点总结及记录,如果您对 Java、算法 感兴趣,可以关注我的动态,我们一起学习。 用知识改变命运,让我们的家人过上更好的生活。 目录一、杨辉三角的介绍二、杨辉三角的算法思想三、代码实现1.第一种写法2.第二种写法 一、杨辉三角的介绍 百度
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
Python 编程实用技巧
Python是一门很灵活的语言,也有很多实用的方法,有时候实现一个功能可以用多种方法实现,我这里总结了一些常用的方法,并会持续更新。
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,
程序员:我终于知道post和get的区别
IT界知名的程序员曾说:对于那些月薪三万以下,自称IT工程师的码农们,其实我们从来没有把他们归为我们IT工程师的队伍。他们虽然总是以IT工程师自居,但只是他们一厢情愿罢了。 此话一出,不知激起了多少(码农)程序员的愤怒,却又无可奈何,于是码农问程序员。 码农:你知道get和post请求到底有什么区别? 程序员:你看这篇就知道了。 码农:你月薪三万了? 程序员:嗯。 码农:你是怎么做到的? 程序员:
"狗屁不通文章生成器"登顶GitHub热榜,分分钟写出万字形式主义大作
前言 GitHub 被誉为全球最大的同性交友网站,……,陪伴我们已经走过 10+ 年时间,它托管了大量的软件代码,同时也承载了程序员无尽的欢乐。 上周给大家分享了一篇10个让你笑的合不拢嘴的Github项目,而且还拿了7万+个Star哦,有兴趣的朋友,可以看看, 印象最深刻的是 “ 呼吸不止,码字不停 ”: 老实交代,你是不是经常准备写个技术博客,打开word后瞬间灵感便秘,码不出字? 有什么
推荐几款比较实用的工具,网站
1.盘百度PanDownload 这个云盘工具是免费的,可以进行资源搜索,提速(偶尔会抽风????) 不要去某站买付费的???? PanDownload下载地址 2.BeJSON 这是一款拥有各种在线工具的网站,推荐它的主要原因是网站简洁,功能齐全,广告相比其他广告好太多了 bejson网站 3.二维码美化 这个网站的二维码美化很好看,网站界面也很...
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU
相关热词 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片 c# 图片颜色调整 最快 c#多张图片上传 c#密封类与密封方法
立即提问