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

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

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. Hadoop实战2:MapReduce编程-WordCount实例-streaming-python环境

    这是搭建hadoop环境后的第一个MapReduce程序: 基于hadoop streaming的python的脚本: 1 map.py文件,把文本的内容划分成单词: #!/usr/bin/pytho ...

  2. :parent 匹配含有子元素或者文本的元素

    描述: 查找所有含有子元素或者文本的 td 元素 HTML 代码: <table> <tr><td>Value 1</td><td>< ...

  3. css中的选择器

    选择器            说明    *                通用元素选择器,匹配任何元素    E                标签选择器,匹配所有使用E标签(所有HTML元素)的元 ...

  4. linux设备驱动归纳总结(四):3.抢占和上下文切换【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-65711.html linux设备驱动归纳总结(四):3.抢占和上下文切换 xxxxxxxxxxxxx ...

  5. 基于mjpg_streamer视频服务器移植【转】

    本文转载自:http://blog.csdn.net/wavemcu/article/details/7539560 MJPG简介: MJPG是MJPEG的缩写,但是MJPEG还可以表示文件格式扩展名 ...

  6. CSS修改方法

    1.在IE中,大部分情况下默认margin = 0px padding = 0px,但在Chrome中需要写明 在css.css文件开头加上(要加在最上面) html,body,ul,ol,li,ta ...

  7. 在CentOS之上搭建VMware Player 7

    1.下载VMware-Player-7.1.2安装包 百度网盘下载地址: 链接:http://pan.baidu.com/s/1nudfo6H 密码:oemc 直接下载地址: https://down ...

  8. JavaEE基础(六)

    1.面向对象(面向对象思想概述) A:面向过程思想概述 第一步 第二步 B:面向对象思想概述 找对象(第一步,第二步) C:举例 买煎饼果子 洗衣服 D:面向对象思想特点 a:是一种更符合我们思想习惯 ...

  9. HDU-1042 N!

    首先明白这是大数问题,大数问题大多采用数组来实现.如何进位.求余等.比如1047 (Integer Inquiry): 对于1042问题 计算10000以内数的阶乘,因为10000的阶乘达到35660 ...

  10. 【转】SVN 查看历史信息

    转载地址:http://lee2013.iteye.com/blog/1074457 SVN 查看历史信息 通过svn命令可以根据时间或修订号去除过去的版本,或者某一版本所做的具体的修改.以下四个命令 ...