当前位置: 首页 > news >正文

上海网站建设开/百度搜索首页

上海网站建设开,百度搜索首页,公司电脑做网站,珠海市住房城乡建设官网概述很多朋友对Oracle数据库中的一些类型会很容易混淆,其中最容易混淆的应该就是oracle数据库int、number和char、varchar、varchar2类型了,下面针对这两个做一下区分。一、oracle中int与number的区别oracle本来就没有int类型,为了与别的数据…

概述

很多朋友对Oracle数据库中的一些类型会很容易混淆,其中最容易混淆的应该就是oracle数据库int、number和char、varchar、varchar2类型了,下面针对这两个做一下区分。


一、oracle中int与number的区别

oracle本来就没有int类型,为了与别的数据库兼容,新增了int类型作为number类型的子集。int类型只能存储整数;number可以存储浮点数,也可以存储整数;

number(8,1)存储小数位为1位,总长度为8的浮点数,如果小数位数不足,则用0补全;

number(8)存储总长度为8的整数;

int相当于number(22),存储总长度为22的整数。

实例:

1、环境模拟

--创建表结构create table tab(id0 int,id1 number,id2 number(8,1),id3 number(8));--插入测试数据insert into tab select 1,1.5,1.6,8 from dual;insert into tab select 1,1.55,1.6,8 from dual;insert into tab select 1,1.595,1,8 from dual;commit;select * from tab;
9f92ee3ddccd6b2529a975fbf77bfb20.png

2、查询数据字典表dba_tab_columns

select table_name,column_name,data_type,data_length,data_precision,data_scale from dba_tab_columns a where table_name='TAB' and owner='GLOGOWNER' order by column_id;
0a382587da2ba1109f0185f8fb91fdbf.png

说明:

  • Data_type表示字段类型;
  • Data_length表示字段类型的长度;
  • Data_Precision表示字段类型的精度的总长度,如果为null,表示精度的总长度不固定,最长为Data_Length;
  • Data_scale表示字段类型的精度范围,如果为0,表示只能存储为整数,如果为null,表示可以存储整数或者浮点数,浮点数位数不确定,如果为整数,表示存储的精度位数。

查询dba_tab_columns表,发现tab表中ID0字段类型int已经被转换为number(22)。


二、oracle中char、varchar、varchar2的区别

VARCHAR2是Oracle提供的特定数据类型,Oracle可以保证VARCHAR2在任何版本中该数据类型都可以向上和向下兼容。oracle中建议使用varchar2,VARCHAR不建议使用。

43ffc7a8bb71f613b43360b45cdeb8cb.png

1.char占用固定的字节控件,例如char(20),abc在该字段中存储为abc+17个空格;

2.varchar是标准sql的写法,可以存储空字符串;

3.varchar2是oracle特有的字段,varchar2(20)表示该字段最大长度为20,实际存储的是数据的长度;

具体到NVARCHAR2和VARCHAR2的区别,从使用角度来看区别在于:

NVARCHAR2在计算长度时和字符集相关的,例如数据库是中文字符集时以长度10为例,则

1、NVARCHAR2(10)是可以存进去10个汉字的,如果用来存英文也只能存10个字符。

2、而VARCHAR2(10)的话,则只能存进5个汉字,英文则可以存10个。

NVARCHAR2 DatatypeThe NVARCHAR2 datatype is a Unicode-only datatype. When you create a table with an NVARCHAR2 column, you supply the maximum number of characters it can hold. Oracle subsequently stores each value in the column exactly as you specify it, provided the value does not exceed the maximum length of the column.The maximum length of the column is determined by the national character set definition. Width specifications of characterdatatype NVARCHAR2 refer to the number of characters. The maximum column size allowed is 4000 bytes. Please refer to Oracle Database Globalization Support Guide for information on Unicode datatype support.VARCHAR2 DatatypeThe VARCHAR2 datatype specifies a variable-length character string. When you create a VARCHAR2 column, you supply the maximum number of bytes or characters of data that it can hold. Oracle subsequently stores each value in the column exactly as you specify it, provided the value does not exceed the column's maximum length of the column. If you try to insert a value that exceeds the specified length, then Oracle returns an error.You must specify a maximum length for a VARCHAR2 column. This maximum must be at least 1 byte, although the actual string stored is permitted to be a zero-length string (''). You can use the CHAR qualifier, for example VARCHAR2(10 CHAR), to givethe maximum length in characters instead of bytes. A character is technically a code point of the database character set. CHAR and BYTE qualifiers override the setting of the NLS_LENGTH_SEMANTICS parameter, which has a default of bytes. For performance reasons, Oracle recommends that you use the NLS_LENGTH_SEMANTICS parameter to set length semantics and thatyou use the BYTE and CHAR qualifiers only when necessary to override the parameter. The maximum length of VARCHAR2 data is 4000 bytes. Oracle compares VARCHAR2 values using nonpadded comparison semantics.To ensure proper data conversion between databases with different character sets, you must ensure that VARCHAR2 data consistsof well-formed strings. See Oracle Database Globalization Support Guide for more information on character set support.VARCHAR DatatypeDo not use the VARCHAR datatype. Use the VARCHAR2 datatype instead. Although the VARCHAR datatype is currently synonymous with VARCHAR2, the VARCHAR datatype is scheduled to be redefined as a separate datatype used for variable-length characterstrings compared with different comparison semantics.

后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下~

48503ed5ca4c881ccec2d46e003f41c5.gif
http://www.lbrq.cn/news/1288279.html

相关文章:

  • 织梦图片网站/网站建设明细报价表
  • 宜昌做网站公司/网站推广系统
  • 做网站一般用什么程序/河南网站网络营销推广
  • 做鼻翼整形整形的网站/南京百度seo排名优化
  • php会了 怎么做网站/seo优化的内容有哪些
  • 做网站需要什么硬件环境/网站优化排名操作
  • 什么网站做软件任务挣钱/竞价排名机制
  • 深圳网站建设吗/百度推广的广告靠谱吗
  • 什么网站做教育的比较多/新闻头条今日新闻
  • 郑州做网站费用/武汉大学人民医院东院
  • 神马站长平台/网站统计分析平台
  • 做企业网站进行推广要多少钱/创量广告投放平台
  • 美团外卖网站开发/百度手机助手苹果版
  • 怎么在建设厅网站报名/seo基础教程使用
  • 网站建设与发布的预算/旺道seo推广效果怎么样
  • 做网站的技术性说明/谷歌 chrome 浏览器
  • 建设企业网站管理系统目的/营销网站系统
  • 不良网站进入窗口免费正能量/二级域名网址查询
  • 极速微网站建设cms/seo如何优化
  • wordpress怎么更改地址/seo服务外包客服
  • 西安商城网站建设制作/html制作网站
  • 东莞网站建议/设计公司网站模板
  • 外贸网站搜索引擎优化方法/太原seo代理商
  • 微信辅助做单网站/seo挂机赚钱
  • 5118站长平台/西安关键词网站排名
  • 免费做图网站/网站如何seo推广
  • ps网站首页设计/b2b平台
  • css如何让网站首字放大/网络营销公司名字
  • 大学做机器人比赛的网站论坛/企业营销策划论文
  • 微网站 微信/东莞seo网站推广建设
  • 专题:2025电商增长新势力洞察报告:区域裂变、平台垄断与银发平权|附260+报告PDF、原数据表汇总下载
  • OpenCV 图像变换全解析:从镜像翻转到仿射变换的实践指南
  • 人形机器人_双足行走动力学:Maxwell模型及在拟合肌腱特性中的应用
  • 报告研读——103页数据资产价值实现研究报告( 2023)【附全文阅读】
  • 锁定锁存器 | 原理 / 应用 / 时序
  • 【C语言进阶】柔性数组