CUBRID学习笔记 24 数据类型1
---恢复内容开始---
一 数字类型 注意小数的四舍五入问题
1数字型
|
Type |
Bytes |
Mix |
Max |
Exact/approx. |
|---|---|---|---|---|
|
SHORT |
2 |
-32,768 |
32,767 |
exact numeric |
|
INTEGER |
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 |
16 |
precision p: 1 |
precision p: 38 |
exact numeric |
|
FLOAT |
4 |
-3.402823466E+38 (ANSI/IEEE 754-1985 standard) |
+3.402823466E+38 |
approximate numeric |
|
DOUBLE |
8 |
-1.7976931348623157E+308 ANSI/IEEE 754-1985 standard) |
+1.7976931348623157E+308(ANSI/IEEE 754-1985 standard) |
approximate numeric |
|
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) |
2038-01-19 03:14:07 (GMT) |
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的更多相关文章
- CUBRID学习笔记 27 数据类型4
范围比较 数字和字符串比较 字符串被转为double SELECT i FROM t WHERE i <= all {'11','12'}; i ============= 1 2 3 4 字符 ...
- CUBRID学习笔记 26 数据类型3cubrid教程
接上面的集合 集合之 set 每个集合元素是不同的值, 但是类型只能是一种.也可以有其他表的记录 如下 CREATE TABLE set_tbl ( col_1 set(CHAR(1))); INSE ...
- CUBRID学习笔记 25 数据类型2
---恢复内容开始--- 6枚举类型 语法 <enum_type> : ENUM '(' <char_string_literal_list> ')' <char_str ...
- CUBRID学习笔记 11 数据类型之日期
datetime 虽然和mysql很相像,但是日期类型和mysql是不一样的.和sqlserver差不多. 如YYYY-MM-DD hh:mi:ss.fff or mm/dd/yyyy hh:mi:s ...
- CUBRID学习笔记 48查询优化
cubrid的中sql查询语法 查询优化 c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com ...
- CUBRID学习笔记 47 show
cubrid的中sql查询语法show c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com . ...
- CUBRID学习笔记 46 PREPARED set Do
cubrid的中sql查询语法PREPARED set Do c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650 ...
- CUBRID学习笔记 45 REPLACE DELETE MERGE 教程
c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com . 过错 ------ 官方文档是英文的, ...
- CUBRID学习笔记 44 UPDATE 触发器 更新多表 教程
cubrid的中sql查询语法UPDATE c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com ...
随机推荐
- 161121、hibernate导致数据出错的两个地方
一.在查询出来的对象上直接设置属性(该属性配置了可以持久化,如果不是可持久化的就没有关系). 出错的代码:(查询用的不好也会导致数据更新哦) Pagination pagination = group ...
- Spring+Mybatis+jQuery.Pagination.js异步分页及JsonConfig的使用
在开发工作中经常用到异步分页,这里简单整理一下资料. 一.Controller方法 package com.lwj.controller; import javax.servlet.http.Http ...
- Hibernate,JPA注解@OneToMany_Set
用例代码如下: 数据库DDL语句 1,CAT表 create table CAT ( id CHAR) not null, create_time ), update_time ), cat_name ...
- discuz模板文件列表
template/default/common模板公共文件夹,全局相关 |--block_forumtree.htm 树形论坛版块分支js文件 |--block_thread.htm特 ...
- Oracle性能优化--DBMS_PROFILER
想看到过程或者函数执行每一步的过程:想看到每一步所占的时间吗?借助profiler吧:它可以满足你来分析过程/函数执行比较久:可以直接快速找到病因:从而可以优化那一步需要优化下. 一 ...
- Java JDBC 驱动 MySQL
MySQL: 1>下载地址:http://www.mysql.com/products/connector/ 2> //jdbc:[数据库类型]://[ip地址]:[端口号]/[数据库名] ...
- 自己封装的OKhttp请求
package com.create.qdocumentimtest.rxjavatest; import com.squareup.okhttp.Callback; import com.squar ...
- python 补充-decode和encode
1. decode与encode转码 在Python3中默认编码就是uncode,encode转成Byte类型 在Python2中默认编码就是ascii window下默认编码是GBK decode( ...
- day3 python 集合 文件
字典是无序的,列表是有序的 a='zhangsan' print (a[1]) a[2]=222 #字符串不能赋值 集合(set):把不同的元素组成一起形成集合 info=[1,2,34,5,6,7] ...
- 获取SqlServer2005表结构(字段,主键,外键,递增,描述)
1.获取表的基本字段属性 --获取SqlServer中表结构 SELECT syscolumns.name,systypes.name,syscolumns.isnullable, syscolumn ...