varchar2

What is the max size of VARCHAR2 in PL/SQL and SQL?

点点圈 提交于 2019-11-30 14:27:47
问题 I am on Oracle 10g. In a requirement I need to increase the size of a pl/sql VARCHAR2 variable. It is already at 4000 size. I have read that in PL/SQL, VARCHAR2 can be up to 32767 bytes. For SQL the limit is 4000 bytes Can I increase the size of this variable without worrying about the SQL limit? 回答1: See the official documentation (http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm#i54330) Variable-length character string having maximum length size bytes or characters.

difference between NLS_NCHAR_CHARACTERSET and NLS_CHARACTERSET for Oracle

那年仲夏 提交于 2019-11-30 14:02:38
i have a quick question here, that i would like to know the difference between NLS_NCHAR_CHARACTERSET and NLS_CHARACTERSET setting in oracle ?? from my understanding NLS_NCHAR_CHARACTERSET is for NVARCHAR data types and for NLS_CHARACTERSET would be for VARCHAR2 data types. i tried to test this on my development server which my current settings for CHARACTERSET is as the following :- PARAMETER VALUE ------------------------------ ---------------------------------------- NLS_NCHAR_CHARACTERSET AL16UTF16 NLS_NUMERIC_CHARACTERS ., NLS_CHARACTERSET US7ASCII Then i inserted some Chinese character

Limit listagg function to first 4000 characters [duplicate]

99封情书 提交于 2019-11-30 10:22:50
This question already has an answer here: LISTAGG function: “result of string concatenation is too long” 12 answers Oracle - ORA-01489: result of string concatenation is too long [duplicate] 1 answer I have a query that uses the listagg function to get all rows as a comma delimited string to ultimately be shipped to a big text box. I'm getting the following exception: ORA-01489: result of string concatenation is too long I know the problem is that the query being run to aggregate the data is returning so many rows that the string concatenation that listagg is doing violates the 4000 char limit

Why does an oracle plsql varchar2 variable need a size but a parameter does not?

旧巷老猫 提交于 2019-11-29 07:28:20
Suppose you have this procedure: PROCEDURE f (param VARCHAR2) IS var VARCHAR2(10); BEGIN var := 'hi'; END f; I would like to understand why var needs a length specified, but param does not. I'm having a hard time finding information about this in the oracle docs. Joseph B "Oracle Database derives the length, precision, and scale of an argument from the environment from which the procedure is called." Please check out this related question . Reference: Oracle® Database SQL Reference 10g Release 2 (10.2) Please look under semantics / argument / datatype. The difference is that subprogram

Oracle char varchar2 nvarchar2

旧巷老猫 提交于 2019-11-28 14:40:53
数据库字符集 首先需要强调下 Oracle 的数据库字符集属性会影响字符类型的容量, 可以通过执行该 sql select userenv('language') from dual; 查看 Oracle 的数据库字符集. 如果字符集编码是 16-bit 的,那么每个字符占16位,也就是2字节. 如果字符集编码是 32-bit 的,那么每个字符占32位,也就是4字节. Tips:数据字符集不同的情况下进行数据迁移,可能会出现长度异常的问题. char 示例: char(5) 表示该字段的数据类型为 char ,可存在5个字节长度的字符,不足则自动空格填充,也就是你如果存入一个字符"A",自动会在后面加上4个空格,读取出来会变成"A空格空格空格空格" varchar2 最大长度为4000. 示例: varchar2(50) 标识该字段的数据类型为 varchar ,可存放单个字节长度的字符50个,比如英文/数字,但一个汉字占2个字节长度( 受数据库字符集影响 ). nvarchar2 最大长度为2000. 示例: nvarchar(50) 表示该字段的数据类型为 nvarchar ,可存放单个字节长度的字符50个,不论字符是汉字/英文/数字都只占1个字节长度( 受数据库字符集影响 ). 来源: oschina 链接: https://my.oschina.net/u/2912152

varchar nvarchar char nchar varchar2 nvarchar2

主宰稳场 提交于 2019-11-28 14:40:29
1、char 定长的存储ASCII码字节数据,过去使用这种类型保存数据,但是由于定长势必浪费存储空间;但是效率高 2、varchar 不定长的存储ASCII码字节数据,即使初始化空间为5,如果只存储长度为3的字节,你们也只是占用3个字节的空间;相比char,varchar可以大量节约空间,但是在效率上稍低,原因是长度的判断导致要移位操作,不过这种影响小的可以不用计算,所以在开发中尽量使用varchar; 3、nvarchar 不定长的存储字符数据,这个与varchar的最大区别就是,varchar存储的是字节,而nvarchar存储的字符,也就是说,如果你初始化的空间是5的话,那么意思是申请了5个字符的空间,对于Unicode编码我们知道不同字符所占的字节是不一样的,但是英文只是一个字节就能满足,中文就不一样了,所以,如果你采用nvarchar作为存储英文的话,那就是大量浪费空间。 4、varchar2 varchar2是oracle可变长的数据类型,在SqlServer中称为varchar,他的特点就是可变长,比如定义表的时候采用 FNAME varchar2(20) 意思是FNAME字段最大采用20个 字节 存储,每个字节就是一个8位,也就是 0-127 的ASCII码,实际上这个FNAME的字符串长度就是最大为 20 ,但是不一定为 20;他是不能存储非ASCII码字符的;

Finding rows that don't contain numeric data in Oracle

試著忘記壹切 提交于 2019-11-28 09:04:57
I am trying to locate some problematic records in a very large Oracle table. The column should contain all numeric data even though it is a varchar2 column. I need to find the records which don't contain numeric data (The to_number(col_name) function throws an error when I try to call it on this column). I was thinking you could use a regexp_like condition and use the regular expression to find any non-numerics. I hope this might help?! SELECT * FROM table_with_column_to_search WHERE REGEXP_LIKE(varchar_col_with_non_numerics, '[^0-9]+'); Michael Durrant To get an indicator: DECODE( TRANSLATE

Why does an oracle plsql varchar2 variable need a size but a parameter does not?

余生颓废 提交于 2019-11-28 01:16:07
问题 Suppose you have this procedure: PROCEDURE f (param VARCHAR2) IS var VARCHAR2(10); BEGIN var := 'hi'; END f; I would like to understand why var needs a length specified, but param does not. I'm having a hard time finding information about this in the oracle docs. 回答1: "Oracle Database derives the length, precision, and scale of an argument from the environment from which the procedure is called." Please check out this related question. Reference: Oracle® Database SQL Reference 10g Release 2

Why does Oracle varchar2 have a mandatory size as a definition parameter?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 14:43:55
问题 I want to know why Oracle needs the size parameter in the definition of the VARCHAR2 . I think that is for constraint. Would it be a better option that oracle takes this parameter as an optional like NUMBER dataType? I often have problems resizing old tables to larger sizes, because sometimes a value is bigger than the size definition of the VARCHAR2 column. It's the same to define a type of VARCHAR2(10 ) or VARCHAR2(1000) . I guess, it's an unnecessary constraint. If not, do you know of a

Impact of defining VARCHAR2 column with greater length

别说谁变了你拦得住时间么 提交于 2019-11-27 08:16:33
What are the effects of defining a column with VARCHAR2(1000) instead of VARCHAR2(10) in Oracle, when the values are not longer than 10 Byte? Does the column only take the space really necessary to store the values, or would that have any negative impacts on the size/performance of tablespaces/indexes? Jeffrey Kemp The answer depends on whether you're talking about a column in a database table, or a variable in a PL/SQL program. Database column The amount of storage used is proportionate to the size of the data stored. PL/SQL variable If the variable is declared with a size 1 to 4000 (11g+) /