(interbase之七) 使用域扩展interbase的数据类型
原创kylixyqh--------------------------------------------------------- 一些人使用过一段时间的interbase后,抱怨说interbase提供的数据类型太少了。的确,与其他关系数据库相比,interbase确实提供了为数不多的数据类型,但是,实际上只要用心思考一下,就会发现interbase的域对象可以帮助我们在基本数据类型的基础上扩展很多有用的数据类型。事实上,经过这种扩展后,你会发现interbase的数据类型基本上和sybase11.9、Ms SqL server2000提供的数据类型相当。 1、逻辑数据类型boolean(取值范围0或1) 有两种方法实现布尔逻辑类型。 方法之一:使用整数0和1代表逻辑真和假。 create domain boolean as smallint default 0 check(value in (0,1)); 方法之二:使用字符'0'和'1'代表逻辑真和假。 create domain boolean as char default '0' check (value in ('0','1')); 2、货币数据类型money、smallmoney 由于interbase6。0的dialect 3已经实现了大型精确数据,完全可以使用numeric类型构造出货币类型。 money类型: create domain money as numeric(18,4); smallmoney类型: create domain smallmoney as numeric(9,4); 你可以根据实际情况改变长度和小数点位数使之符合你的要求。 3、其他整数类型tinyint、bigint tinyint类型(0~255): create domain tinyint as integer check(value between 0 and 255); bigint类型(-2的63次方~2的63次方-1): create domain bigint as numeric(18,0); 4、图像类型image 通过BLOB类型的子类型构造。 create domain image as blob sub_type 0 5、文本类型text 通过BLOB类型的子类型构造。 create domain text as blob sub_type 1 6、用户自定义数据类型 使用域,你可以象其他关系数据库一样创建丰富多彩的功能各异的自定义数据类型。 注:关于interbase6的基本数据类型,请参考有关资料。
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18