我对我的表数据大小有疑问。 如何准确地修复数据类型及其大小。 请帮帮我。
mysql> show create table AssignmentPolicy\G
*************************** 1. row ***************************
Table: AssignmentPolicy
Create Table: CREATE TABLE `AssignmentPolicy` (
`AssignmentPolicyID` int(11) NOT NULL AUTO_INCREMENT,
`AssignmentPolicyGroupID` smallint(3) unsigned DEFAULT NULL,
`AssignmentPolicyName` varchar(50) NOT NULL DEFAULT '',
`AssignmentPolicyTitle` varchar(250) NOT NULL DEFAULT '',
`AssignmentPolicyDescription` tinytext NOT NULL,
`Order` smallint(3) unsigned NOT NULL DEFAULT '0',
`Editable` tinyint(1) unsigned NOT NULL DEFAULT '1',
`DefaultValue` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0',
`Dependency` int(11) DEFAULT NULL,
PRIMARY KEY (`AssignmentPolicyID`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
Tables:
mysql> show create table Item\G
*************************** 1. row ***************************
Table: Item
Create Table: CREATE TABLE `Item` (
`Item_ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Reviewer_User_ID` int(10) unsigned DEFAULT NULL,
`Author_User_ID` int(10) unsigned DEFAULT NULL,
`Status_Code` enum('live','in_progress','needs_revision','ready_for_review','ready_for_final_review','hidden','deprecated') DEFAULT 'in_progress',
`Topic_ID` mediumint(8) unsigned DEFAULT NULL,
`Title` varchar(255) DEFAULT NULL,
`Cognitive_Type` enum('conceptual','quantitative','vocabulary') DEFAULT NULL,
`Difficulty` enum('easy','medium','hard') DEFAULT NULL,
`Description` mediumtext,
`bookQNum` varchar(50) DEFAULT NULL,
`Is_EOC` tinyint(4) NOT NULL DEFAULT '0',
`Propagate_Algos` tinyint(4) NOT NULL DEFAULT '0',
`Regenerate_Algos` tinyint(4) NOT NULL DEFAULT '0',
`Visibility` enum('private','system') DEFAULT 'system',
`Source_Taxonomy` smallint(5) unsigned DEFAULT NULL,
`Date_Created` datetime DEFAULT NULL,
`ItemCopied_ID` int(10) unsigned DEFAULT NULL,
`TemplateCopied_ID` int(10) unsigned DEFAULT NULL,
`ibis_compatible` enum('false','true') NOT NULL DEFAULT 'true',
`sequoia_compatible` enum('false','true') NOT NULL DEFAULT 'false',
PRIMARY KEY (`Item_ID`),
KEY `Topic_ID` (`Topic_ID`),
KEY `Status_Code` (`Status_Code`),
KEY `Author_User_ID` (`Author_User_ID`),
KEY `Reviewer_User_ID` (`Reviewer_User_ID`),
KEY `ItemCopied_ID` (`ItemCopied_ID`),
KEY `TemplateCopied_ID` (`TemplateCopied_ID`),
KEY `Item2Taxonomy` (`Source_Taxonomy`),
CONSTRAINT `Item2Author_User_ID` FOREIGN KEY (`Author_User_ID`) REFERENCES `User` (`userID`) ON UPDATE CASCADE,
CONSTRAINT `Item2content__taxonomy` FOREIGN KEY (`Source_Taxonomy`) REFERENCES `content`.`taxonomy` (`Key`) ON UPDATE CASCADE,
CONSTRAINT `Item2content__topic` FOREIGN KEY (`Topic_ID`) REFERENCES `content`.`topic` (`Key`) ON UPDATE CASCADE,
CONSTRAINT `Item2Item_Copied` FOREIGN KEY (`ItemCopied_ID`) REFERENCES `Item` (`Item_ID`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `Item2Template_Copied` FOREIGN KEY (`TemplateCopied_ID`) REFERENCES `Item` (`Item_ID`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=41885 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
答案 0 :(得分:0)
诸如int之类的数字类型没有动态大小。如果你设置int(11)你设置填充级别,而不是“整数大小”,这是......你知道...毕竟是整数大小。所以在第一次去的时候我会删除所有int / tinyint / etc“(xx)”值,如果不是故意设置填充。如果要更改表中的列,则必须使用ALTER TABLE,这里有一些很好的示例:http://dev.mysql.com/doc/refman/5.1/en/alter-table-examples.html