Calculate row size and max row size for a table Problem:

Is there any way of calculating number of bytes occupied by the table creation, i know that you can get some information from information_schema.tables but that information is not accurate enough.           

What actually required is the number of bytes according to the definition of the table for innodb only and collation could also be considered as utf-8-general-ci

For example a table test is as following


  create table test
  (
  col1 varchar(25),
  col2 int,
  col3 varchar(3),
  col4 char(15),
  col5 datetime
  );  


Now would require to know the total row size that can be accumulated in one row according to the types of columns in the table.

Found a some sort of similar solution in MSSQL but need its MySQL version

Script to estimate row sizes for any table

Any help is much appreciated.
After much of thinking and researching found one answer which really helped in achieving what  was required. It is a perl script and reference link is 

http://dev.mysql.com/doc/refman/5.6/en/storage-requirements.html

#!/usr/bin/perl
use strict;
$| = 1;

my %DataType = (
"TINYINT"=&gt;1, "SMALLINT"=&gt;2, "MEDIUMINT"=&gt;3, "INT"=&gt;4, "INTEGER"=&gt;4, "BIGINT"=&gt;8,
"FLOAT"=&gt;'$M&lt;=24?4:8', "DOUBLE"=&gt;8,
"DECIMAL"=&gt;'int(($M-$D)/9)*4+int(((($M-$D)%9)+1)/2)+int($D/9)*4+int((($D%9)+1)/2)',
"NUMERIC"=&gt;'int(($M-$D)/9)*4+int(((($M-$D)%9)+1)/2)+int($D/9)*4+int((($D%9)+1)/2)',
"BIT"=&gt;'($M+7)&gt;&gt;3',
"DATE"=&gt;3, "TIME"=&gt;3, "DATETIME"=&gt;8, "TIMESTAMP"=&gt;4, "YEAR"=&gt;1,
"BINARY"=&gt;'$M',"CHAR"=&gt;'$M*$CL',
"VARBINARY"=&gt;'$M+($M&gt;255?2:1)', "VARCHAR"=&gt;'$M*$CL+($M&gt;255?2:1)',
"ENUM"=&gt;'$M&gt;255?2:1', "SET"=&gt;'($M+7)&gt;&gt;3',
"TINYBLOB"=&gt;9, "TINYTEXT"=&gt;9,
"BLOB"=&gt;10, "TEXT"=&gt;10,
"MEDIUMBLOB"=&gt;11, "MEDIUMTEXT"=&gt;11,
"LONGBLOB"=&gt;12, "LONGTEXT"=&gt;12
);

my %DataTypeMin = (
"VARBINARY"=&gt;'($M&gt;255?2:1)', "VARCHAR"=&gt;'($M&gt;255?2:1)'
);

my ($D, $M, $S, $C, $L, $dt, $dp ,$bc, $CL);
my $fieldCount = 0;
my $byteCount = 0;
my $byteCountMin = 0;
my @fields = ();
my $fieldName;
my $tableName;
my $defaultDbCL = 1;
my $defaultTableCL = 1;
my %charsetMaxLen;
my %collationMaxLen;

open (CHARSETS, "mysql -B --skip-column-names information_schema -e 'select CHARACTER_SET_NAME,MAXLEN from CHARACTER_SETS;' |");
%charsetMaxLen = map ( ( /^(\w+)/ =&gt; /(\d+)$/ ), &lt;CHARSETS&gt;);
close CHARSETS;

open (COLLATIONS, "mysql -B --skip-column-names information_schema -e 'select COLLATION_NAME,MAXLEN from CHARACTER_SETS INNER JOIN COLLATIONS USING(CHARACTER_SET_NAME);' |");
%collationMaxLen = map ( ( /^(\w+)/ =&gt; /(\d+)$/ ), &lt;COLLATIONS&gt;);
close COLLATIONS;

open (TABLEINFO, "mysqldump -d --compact ".join(" ",@ARGV)." |");

while (&lt;TABLEINFO&gt;) {
chomp;
if ( ($S,$C) = /create database.*?`([^`]+)`.*default\scharacter\sset\s+(\w+)/i ) {
$defaultDbCL = exists $charsetMaxLen{$C} ? $charsetMaxLen{$C} : 1;
print "Database: $S".($C?" DEFAULT":"").($C?" CHARSET $C":"")." (bytes per char: $defaultDbCL)\n\n";
next;
}
if ( /^create table\s+`([^`]+)`.*/i ) {
$tableName = $1;
@fields = ();
next;
}
if ( $tableName &amp;&amp; (($C,$L) = /^\)(?:.*?default\scharset=(\w+))?(?:.*?collate=(\w+))?/i) ) {
$defaultTableCL = exists $charsetMaxLen{$C} ? $charsetMaxLen{$C} : (exists $collationMaxLen{$L} ? $collationMaxLen{$L} : $defaultDbCL);
print "Table: $tableName".($C||$L?" DEFAULT":"").($C?" CHARSET $C":"").($L?" COLLATION $L":"")." (bytes per char: $defaultTableCL)\n";
$tableName = "";
$fieldCount = 0;
$byteCount = 0;
$byteCountMin = 0;
while ($_ = shift @fields) {
if ( ($fieldName,$dt,$dp,$M,$D,$S,$C,$L) = /\s\s`([^`]+)`\s+([a-z]+)(\((\d+)(?:,(\d+))?\)|\((.*)\))?(?:.*?character\sset\s+(\w+))?(?:.*?collate\s+(\w+))?/i ) {
$dt = uc $dt;
if (exists $DataType{$dt}) {
if (length $S) {
$M = ($S =~ s/(\'.*?\'(?!\')(?=,|$))/$1/g);
$dp = "($M : $S)"
}
$D = 0 if !$D;
$CL = exists $charsetMaxLen{$C} ? $charsetMaxLen{$C} : (exists $collationMaxLen{$L} ? $collationMaxLen{$L} : $defaultTableCL);
$bc = eval($DataType{$dt});
$byteCount += $bc;
$byteCountMin += exists $DataTypeMin{$dt} ? $DataTypeMin{$dt} : $bc;
} else {
$bc = "??";
}
$fieldName.="\t" if length($fieldName) &lt; 8;
print "bytes:\t".$bc."\t$fieldName\t$dt$dp".($C?" $C":"").($L?" COLL $L":"")."\n";
++$fieldCount;
}
}
print "total:\t$byteCount".($byteCountMin!=$byteCount?"\tleast: $byteCountMin":"\t\t")."\tcolumns: $fieldCount\n\n";
next;
}
push @fields, $_;
}
close TABLEINFO;


Thanks all for great help.