0

This error happens when I use long as primary key to create table. I've already checked MySQL error: key specification without a key length but I think it does not solve my problem since I'm not using text or blob as index.

I can not figure out why long weng_id as primary key but it shows BLOB/TEXT column weng_id

SQL:

CREATE TABLE `ContentRepository`.`无标题`  (
  `weng_id` long NOT NULL,
  `content_type` tinyint(0) NOT NULL DEFAULT 0,
  `store_time` datetime(0) NOT NULL ON UPDATE CURRENT_TIMESTAMP(0),
  `create_time` datetime(0) NOT NULL,
  `modify_time` datetime(0) NOT NULL,
  `weng_url` varchar(1000) NOT NULL,
  `algorithm_tags` varchar(1000) NULL,
  `words` varchar(1000) NULL,
  `operate_tags` varchar(1000) NULL,
  `mdd_id` bigint(0) NULL,
  `related_mdd_ids` varchar(1000) NULL,
  `related_pois` varchar(1000) NULL,
  `uid` bigint(0) NOT NULL,
  `user_level` tinyint(0) NOT NULL,
  `user_contribution_score` double NULL,
  `status` tinyint(0) NOT NULL,
  `check_status` tinyint(0) NULL,
  `checked_time` datetime(0) NULL,
  `static_score` double NULL,
  `static_level` int(0) NULL,
  `dynamic_level` int(0) NULL,
  `dynamic_score` double NULL,
  `show_channel` int(0) NULL,
  `show_num` bigint(0) NULL,
  `click_num` bigint(0) NULL,
  `favorite_num` bigint(0) NOT NULL,
  `comment_num` bigint(0) NOT NULL,
  `share_num` bigint(0) NOT NULL,
  `collect_num` bigint(0) NOT NULL,
  `weng_type` tinyint(0) NOT NULL,
  `pricture_urls` varchar(1000) NOT NULL,
  `video_url` varchar(1000) NULL,
  `content` varchar(8000) NULL,
  `weng_level` tinyint(0) NOT NULL,
  `weng_category` tinyint(0) NOT NULL,
  `picture_num` int(0) NOT NULL,
  PRIMARY KEY (`weng_id`),
  INDEX `idx_create`(`create_time`) USING BTREE,
  INDEX `idx_modify`(`modify_time`) USING BTREE,
  INDEX `idx_store`(`store_time`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
xingbin
  • 27,410
  • 9
  • 53
  • 103

1 Answers1

2

long is probably not the type you think it is. You probably want bigint:

CREATE TABLE `ContentRepository`.`无标题`  (
  `weng_id` bigint NOT NULL,
  `content_type` tinyint(0) NOT NULL DEFAULT 0,
   . . .
)

long is a large string (mediumtext). It is not suitable for indexing in general.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786