Varchar2 size how to decide?
When you execute a complicate store procedure, maybe it will execute a long time, maybe you want to change some logic,
And retry, but when you recreate or replace, you will get error, the object is locked.
So just try this.
https://zhefeng.wordpress.com/2010/05/25/cant-compile-a-stored-procedure-when-its-locked/
I read that oversizing a varchar2 column in a table doesn't affect storage space, but does effect query performance.
http://hrivera99.blogspot.com/2008/05/why-is-varchar2-oversizing-bad.html
Varchar2(4000 byte)
set serveroutput on;
declare
v_test varchar2(9) ;
v_test2 varchar2(3 char);
begin
v_test := '人民隊';
v_test2 :='人民隊';
DBMS_OUTPUT.PUT_LINE('*' || v_test || '*');
DBMS_OUTPUT.PUT_LINE('*' || v_test2 || '*');
end;
--Error report -
--ORA-06502: PL/SQL: numeric or value error: character string buffer too small
set serveroutput on;
declare
v_test varchar2(9 byte) ;
v_test2 varchar2(3 char);
begin
v_test := '人民隊';
v_test2 :='人民隊';
DBMS_OUTPUT.PUT_LINE('*' || length( v_test) || '*');---return char count
DBMS_OUTPUT.PUT_LINE('*' || lengthb( v_test2) || '*');--return bytes count
end;
--3
--9
- The database uses the length of a variable when allocating memory for PL/SQL collections. As that memory comes out of the PGA supersizing the variable declaration can lead to programs failing because the server has run out of memory.
- Supersized columns create problems for compound indexes. The following is on a database with 8K block
- columns sizes are a form of error checking. If the column is supposed to be ten characters long and some autonomic process is trying to load a thousand characters then something is wrong.
Datatype |
Description |
Column Length / Default Values |
CHAR [(size [BYTE | CHAR])] |
Fixed-length character data of length size bytes or characters. |
Fixed for every row in the table (with trailing blanks); maximum size is 2000 bytes per row, default size is 1 byte per row. When neither BYTE nor CHAR is specified, the setting of NLS_LENGTH_SEMANTICS at the time of column creation determines which is used. Consider the character set (single-byte or multibyte) before setting size. |
VARCHAR2 (size [BYTE | CHAR]) |
Variable-length character data, with maximum length size bytes or characters. BYTE or CHAR indicates that the column has byte or character semantics, respectively. A size must be specified. |
Variable for each row, up to 4000 bytes per row. When neither BYTE nor CHAR is specified, the setting ofNLS_LENGTH_SEMANTICS at the time of column creation determines which is used. Consider the character set (single-byte or multibyte) before setting size. |
NCHAR [(size)] |
Fixed-length Unicode character data of length size characters. The number of bytes is twice this number for the AL16UTF16 encoding and 3 times this number for the UTF8 encoding.) |
Fixed for every row in the table (with trailing blanks). The upper limit is 2000 bytes per row. Default sizeis 1 character. |
NVARCHAR2 (size) |
Variable-length Unicode character data of maximum length size characters. The number of bytes may be up to 2 times size for a the AL16UTF16 encoding and 3 times this number for the UTF8 encoding. A sizemust be specified. |
Variable for each row. The upper limit is 4000 bytes per row |
DATE |
Fixed-length date and time data, ranging from Jan. 1, 4712 B.C.E. to Dec. 31, 9999 C.E. |
Fixed at 7 bytes for each row in the table. Default format is a string (such as DD-MON-RR) specified by theNLS_DATE_FORMAT parameter. |
Pasted from <http://docs.oracle.com/cd/B12037_01/appdev.101/b10795/adfns_ty.htm>
The lengths of CHAR and VARCHAR2 columns can be specified as either bytes or characters.
The lengths of NCHAR and NVARCHAR2 columns are always specified in characters, making them ideal for storing Unicode data, where a character might consist of multiple bytes.
Pasted from <http://docs.oracle.com/cd/B12037_01/appdev.101/b10795/adfns_ty.htm>
Varchar2 size how to decide?的更多相关文章
- Oracle中varchar,varchar2,nvarchar,nvarchar2的区别及其它数据类型描述
--varchar,varchar2 联系: 1.varchar/varchar2用于存储可变长度的字符串 比如varchar(20),存入字符串'abc',则数据库中该字段只占3个字节,而不是20个 ...
- Oracle varchar2 4000
关于oracle varchar2 官方文档的描述 VARCHAR2 Data Type The VARCHAR2 data type specifies a variable-length char ...
- Oracle CHAR,VARCHAR,VARCHAR2,nvarchar类型的区别与使用(转载)
一 varchar,varchar2,nvarchar,nvarchar2 四个类型都属于变长字符类型, varchar和varchar2的区别在与后者把所有字符都占两字节,前者只对汉字和全角等字符占 ...
- oracle之 Oracle LOB 详解
一. 官方说明 Oracle 11gR2 文档: LOB Storage http://download.oracle.com/docs/cd/E11882_01/appdev.112/e18294 ...
- Datatypes translation between Oracle and SQL Server
Datatypes translation between Oracle and SQL Server part 1: character, binary strings Datatypes tran ...
- vchar2和nvchar2
Oracle中varchar2 nvarchar2 VARCHAR2(size),可变长度的字符串,其最大长度为 size 个字节.size 的最大值是 4000,而最小值是 1.您必须指定一个 VA ...
- Oracle建表
1.oracle数据库中的多种数据结构: 1.表结构 存储数据 2.视图 一张表或多张表中数据的字节 3.sequence 主要用来生成主键值 4.index 提高检索性能 我们 ...
- oracle的基本数据类型(转载)
数据类型是在设计表结构中需要定义的,选择适当的数据类型可以节省存储空间,提高运算效率. Oracle数据类型主要包括 1.字符型 适合保存字符串类型的数据,如姓名.地址.简介等等. 如:char(20 ...
- Oracle中的数据类型
数据类型 数据类型是在设计表结构中需要定义的,选择适当的数据类型可以节省存储空间,提高运算效率. Oracle数据类型主要包括 1.字符型 适合保存字符串类型的数据,如姓名.地址.简介等等. 如:ch ...
随机推荐
- 操作AppConfig.xml中AppSettings对应值字符串
//查询AppSettings的key public static List sql() { List list = new List(); ...
- ActiveReports 报表控件官方中文入门教程 (2)-创建、数据源、浏览以及发布
本篇文章将阐述首次使用 ActiveReports 报表控件 的方法,包括添加报表文件.绑定数据源以及如何发布报表等内容. ActiveReports 报表控件官方中文入门教程 (1)-安装.激活以及 ...
- [Tool] 透过PowerPoint Online在部落格文章里内嵌简报
[Tool] 透过PowerPoint Online在部落格文章里内嵌简报 前言 讲课的时候,用PowerPoint做简报,好像已经成了讲课的惯例.而在课后,将课堂简报整理成部落格的文章,如果单纯是在 ...
- CSS层次选择器温故-2
1.层次选择器 通过HTML的DOM元素间的层次关系获取元素,层次关系包括后代.父子.相邻兄弟和通用兄弟,通过其中某类关系可以方便快捷地选定需要的元素 2.语法 3.兼容性 IE7以及以上版本 4.后 ...
- ArcEngine 0x8004023C
在进行缓冲区查询时,查询的并是不要素本身的范围,而是缓冲一定半径,所以用到了ITopologicalOperator接口,主要是利用其buffer方法,代码如下: IFeatureClass pFea ...
- andriod 带看括弧的计算器
界面 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=& ...
- MVC中的CSRF解决方案
我们使用Ajax访问请求的时候,攻击者可能盗用了用户身份,以用户合法身份发送恶意请求. 具体预防措施, 1.在Html表单里面使用@Html.AntiForgeryToken(),这玩意会生成一对加密 ...
- C语言内存对齐详解
一.字节对齐基本概念 现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,但实际情况是在访问特定类型变量的时候经常在特定的内存地址访问,这就需要各种类型 ...
- 推导大O阶方法
用大写O()来体现算法时间复杂度的记法,我们称之为大O阶记法. O(1)叫做常数阶:O(n)叫做线性阶:O(n^2)叫做平方阶. 1.用常数1取代运行时间中的所有加法常数. 2.在修改后的运行次数函 ...
- 【转】IOS动画的实现,其实很简单
动画效果提供了状态或页面转换时流畅的用户体验,在iOS系统中,咱们不需要自己编写绘制动画的代码,Core Animation提供了丰富的api来实现你需要的动画效果.UIKit只用UIView来展示动 ...