About Blob and Binary in Database when Create Table

Topics: Developer Forum
Sep 3, 2008 at 10:32 AM
In DataBase MYSQL:

the length of Blob can not be set. Blob used to save something like picture or big binary content.

the length of Binary must be set. min is 1;

when I use mysql,  the dbEntry only create "Binary Field" when the class field is byte[],and set length is 1; It's not what I want.

but in oracle,you set TypeNames[DataType.Binary] = "BLOB";(I do not test oracle)

----------------------------------------------------------------
我觉得string 方式设定的特别好,如果有length就使用nvarchar,没有length就用ntext
我觉得byte[]是否也应该如此呢?如果没有length就使用blob,有length属性就使用binary
-----------------------------------------------------------------
以上是mysql.

在sqlite里面的blob是貌似可以设定长度的。也可以不设定。这个还没测试,稍后奉上。
type ::= typename <BIG>|</BIG>
typename <BIG>(</BIG> number <BIG>)</BIG> <BIG>|</BIG>
typename <BIG>(</BIG> number <BIG>,</BIG> number <BIG>)</BIG>


Sep 3, 2008 at 11:11 AM
IN MYSQL

CREATE TABLE `Article2` (
 `Id` bigint AUTO_INCREMENT NOT NULL PRIMARY KEY,
 `Url` varchar (255) NOT NULL ,
 `Content` BLOB NULL
);



CREATE TABLE `Article2` (
 `Id` bigint AUTO_INCREMENT NOT NULL PRIMARY KEY,
 `Url` varchar (255) NOT NULL ,
 `Content` BINARY NULL
);

这两个不同,第二个会建立一个BINARY 列,长度只有1.
第一个建立一个不限制长度的blob列
Coordinator
Sep 3, 2008 at 12:21 PM
It's hard for all databases and validation and so on.
I'll think about it.
But I think it may take times.