---恢复内容开始---

一 数字类型  注意小数的四舍五入问题

1数字型

Type

Bytes

Mix

Max

Exact/approx.

SHORT
SMALLINT

2

-32,768

32,767

exact numeric

INTEGER
INT

4

-2,147,483,648

+2,147,483,647

exact numeric

BIGINT

8

-9,223,372,036,854,775,808

+9,223,372,036,854,775,807

exact numeric

NUMERIC
DECIMAL

16

precision p: 1
scale s: 0

precision p: 38
scale s: 38

exact numeric

FLOAT
REAL

4

-3.402823466E+38 (ANSI/IEEE 754-1985 standard)

+3.402823466E+38
(ANSI/IEEE 754-1985 standard)

approximate numeric
floating point : 7

DOUBLE
DOUBLE PRECISION

8

-1.7976931348623157E+308 ANSI/IEEE 754-1985 standard)

+1.7976931348623157E+308(ANSI/IEEE 754-1985 standard)

approximate numeric
floating point : 15

MONETARY

12

-3.402823466E+38

+3.402823466E+38

approximate numeric

2  bit类型

就是0和1   最大的bit字符串长度1,073,741,823

bit(n)

  • n must be a number greater than 0.
  • If the length of the string exceeds n, it is truncated and filled with 0s.
  • If a bit string smaller than n is stored, the remainder of the string is filled with 0s.
Example

CREATE TABLE bit_tbl(a1 BIT, a2 BIT(1), a3 BIT(8), a4 BIT VARYING);

INSERT INTO bit_tbl VALUES (B'1', B'1', B'1', B'1');

INSERT INTO bit_tbl VALUES (0b1, 0b1, 0b1, 0b1);

INSERT INTO bit_tbl(a3,a4) VALUES (B'1010', B'1010');

INSERT INTO bit_tbl(a3,a4) VALUES (0xaa, 0xaa);

SELECT * FROM bit_tbl;

a1                    a2                    a3                    a4

=========================================================================

X'8'                  X'8'                  X'80'                 X'8'

X'8'                  X'8'                  X'80'                 X'8'

NULL                  NULL                  X'a0'                 X'a'

NULL                  NULL                  X'aa'                 X'aa'

BIT VARYING(n)

  • If the length of the string exceeds n, it is truncated and filled with 0s.
  • The remainder of the string is not filled with 0s even if a bit string smaller than n is stored.
  • n must be a number greater than 0.
Example

CREATE TABLE bitvar_tbl(a1 BIT VARYING, a2 BIT VARYING(8));

INSERT INTO bitvar_tbl VALUES (B'1', B'1');

INSERT INTO bitvar_tbl VALUES (0b1010, 0b1010);

INSERT INTO bitvar_tbl VALUES (0xaa, 0xaa);

INSERT INTO bitvar_tbl(a1) VALUES (0xaaa);

SELECT * FROM bitvar_tbl;

a1                    a2

============================================

X'8'                  X'8'

X'a'                  X'a'

X'aa'                 X'aa'

X'aaa'                NULL

INSERT INTO bitvar_tbl(a2) VALUES (0xaaa);

ERROR: Data overflow coercing X'aaa' to type bit varying.

3  日期型

  • The range of year in DATE is 0001 - 9999 AD.
  • By default, the range of a time value is represented by the 24-hour system
  • The range of TIMESTAMP is between 1970-01-01 00:00:01 - 2038-01-19 03 03:14:07 (GMT). For KST (GMT+9), values from 1970-01-01 00:00:01 to 2038-01-19 12:14:07 can be stored.

格式

  • DATE Type
  • YYYY-MM-DD
  • MM/DD/YYYY
  • TIME Type
  • HH:MM:SS ["AM"|"PM"]
  • DATETIME Type
  • YYYY-MM-DD HH:MM:SS[.msec] ["AM"|"PM"]
  • TIMESTAMP Type
  • YYYY-MM-DD HH:MM:SS ["AM"|"PM"]

Type

bytes

Min.

Max.

Note

DATE

4

0001-01-01

9999-12-31

As an exception, DATE '0000-00-00' format is allowed.

TIME

4

00:00:00

23:59:59

 

TIMESTAMP

4

1970-01-01 00:00:01 (GMT)
1970-01-01 09:00:01 (KST)

2038-01-19 03:14:07 (GMT)
2038-01-19 12:14:07 (KST)

As an exception, TIMESTAMP '0000-00-00 00:00:00' format is allowed.

DATETIME

8

0001-01-01 00:00:0.000

9999-12-31 23:59:59.999

As an exception, DATETIME '0000-00-00 00:00:00' format is allowed.

4  字符串

基本也是varchar nvarchar之类的

CHAR or VARCHAR 长度 1,073,741,823

NCHAR or NCHAR  长度  536,870,911

CSQL语句长度8,192 KB

字符集 可以通过数据库的环境变量设置

转义字符和方法

  • \' : Single quotes (')
  • \" : Double quotes (")
  • \n : Newline, linefeed character
  • \r : Carriage return character
  • \t : Tab character
  • \\ : Backslash
  • \% : Percent sign (%).
  • \_ : Underbar (_).

示例

欢迎转载 ,转载时请保留作者信息。本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com 。 过错

SELECT LENGTH('\\');

char_length('\')

CREATE TABLE t1 (a varchar(200));

INSERT INTO t1 VALUES ('aaabbb'), ('aaa%');

SELECT a FROM t1 WHERE a LIKE 'aaa\%' escape '\\';

a

======================

'aaa%'

---恢复内容结束---

CUBRID学习笔记 24 数据类型1的更多相关文章

  1. CUBRID学习笔记 27 数据类型4

    范围比较 数字和字符串比较 字符串被转为double SELECT i FROM t WHERE i <= all {'11','12'}; i ============= 1 2 3 4 字符 ...

  2. CUBRID学习笔记 26 数据类型3cubrid教程

    接上面的集合 集合之 set 每个集合元素是不同的值, 但是类型只能是一种.也可以有其他表的记录 如下 CREATE TABLE set_tbl ( col_1 set(CHAR(1))); INSE ...

  3. CUBRID学习笔记 25 数据类型2

    ---恢复内容开始--- 6枚举类型 语法 <enum_type> : ENUM '(' <char_string_literal_list> ')' <char_str ...

  4. CUBRID学习笔记 11 数据类型之日期

    datetime 虽然和mysql很相像,但是日期类型和mysql是不一样的.和sqlserver差不多. 如YYYY-MM-DD hh:mi:ss.fff or mm/dd/yyyy hh:mi:s ...

  5. CUBRID学习笔记 48查询优化

    cubrid的中sql查询语法 查询优化 c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com ...

  6. CUBRID学习笔记 47 show

    cubrid的中sql查询语法show c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com . ...

  7. CUBRID学习笔记 46 PREPARED set Do

    cubrid的中sql查询语法PREPARED set Do c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650 ...

  8. CUBRID学习笔记 45 REPLACE DELETE MERGE 教程

    c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com . 过错 ------ 官方文档是英文的, ...

  9. CUBRID学习笔记 44 UPDATE 触发器 更新多表 教程

    cubrid的中sql查询语法UPDATE c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com ...

随机推荐

  1. java运算符优先级记忆口诀

    尊重原创:(口诀)转自http://lasombra.iteye.com/blog/991662 今天看到<java编程思想>中的运算符优先级助记口诀,不过"Ulcer Addi ...

  2. tr DEMO

    测试数据: [weblogic@etp-mall-dev7][/tmp]$ cat msn.txt aaa bbb bbb ccc ccc ddd bbb eee aaa ccc bbb sss 转换 ...

  3. struts2-json-plugin插件实现异步通信

    用例需要依赖的jar: struts2-core.jar struts2-convention-plugin.jar,非必须, struts2-json-plugin.jar org.codehaus ...

  4. Swoole + zphp 改造为专门用来开发接口的框架

    The other problem I had with Laravel Task Scheduling was that i really only wanted something to hand ...

  5. ecshop后台增加模块菜单详细教程(图)

    我们有时候针对ecshop如此开发,想在后台加一些菜单,最模板以前提供过教程,但是并非很系统,今天最模板抛砖引玉图文教程告诉大家:如何在ecshop后台增加模块菜单! 首先需要修改四个文件:inc_p ...

  6. MFC中的CDC,CClientDC,CPaintDC,CWindowDC的区别

    转自 http://blog.csdn.net/guoquan2003/article/details/4534716 CDC是Windows绘图设备的基类. CClientDC:(1)(客户区设备上 ...

  7. js作用域链与this

    this的绑定与function和对象的定义位置无关,是由函数调用时的执行环境所决定的. scope chain是由函数定义时的位置决定的与函数调用时的执行环境无关.

  8. word 排版问题

    1.wps word为何设置了页边距后下面的页边距不变呢 在章节选项卡中,查看章节导航,有可能是文档分节了,光标所在的节已经调整,而你看到页是另一节 2.分栏 选中你要进行分栏的内容,进行分栏,也可以 ...

  9. c# UDP通信

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  10. 过滤器Filter(拦截jsp页面的跳转)案例:

    创建一个 Filter , class类: 其继承于 接口 Filte(接口导包:import javax.servlet.Filter;) 在 web.xml 文件中配置并映射该 Filter. 其 ...