MySQL - 在varchar中存储长度为1000

时间:2015-06-04 22:51:46

标签: mysql innodb varchar

如果我有长度为1000的存储数据,那么使用varchar是个好主意吗?下面是我的脚本和列SR_NOTES是我担心的那个。我用户utf8,引擎是INNODB。和TINYTEXT这样说比较明智吗?我热衷于在不妨碍性能的情况下创建数据库设计。

CREATE TABLE IF NOT EXISTS SROR (
 SROR_ID INT UNSIGNED NOT NULL,
 CRAN_ID INT UNSIGNED NOT NULL,
 SR_TAGS VARCHAR(250) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL, 
 GR_VALUES DECIMAL(4,2), -- 12.25 R
 NOTICE_PERIOD SMALLINT UNSIGNED DEFAULT NULL,
 C_STATUS VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' DEFAULT 'INACTIVE', 
 SR_NOTES VARCHAR(1000) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' DEFAULT NULL, 
 SR_CONTROL VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' DEFAULT NULL, 
 START_DATE DATETIME DEFAULT CURRENT_TIMESTAMP,  
 LAST_UPDATE DATETIME ON UPDATE CURRENT_TIMESTAMP, 
 PRIMARY KEY (SROR_ID, CRAN_ID),
 INDEX idx_SROR_id1 (SROR_ID ASC),
 INDEX idx_SROR_id2 (CRAN_ID ASC),
 CONSTRAINT fk_SROR_C1
  FOREIGN KEY (CRAN_ID)
  REFERENCES R_CONFIG (CRAN_ID)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;

1 个答案:

答案 0 :(得分:0)

考虑使用不同的数据类型,例如TEXT最多可以存储65535个字符。存储笔记的一个很好的选择。

请参阅: What is the MySQL VARCHAR max size?