将 LOB 添加到 Oracle 表有什么问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1091161/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's wrong with adding LOBs to an Oracle table?
提问by Robert Gould
I'm trying to ALTERa table by adding a new CLOB column (on Oracle 10), but it's failing. Giving me an ORA-01735 error. Problem is I can't find out what in particular is wrong with my query by googling around so I figured I'd ask here just in case.
我正在尝试通过添加新的 CLOB 列(在 Oracle 10 上)来更改表,但它失败了。给我一个 ORA-01735 错误。问题是我无法通过谷歌搜索找出我的查询有什么特别的问题,所以我想我会在这里问以防万一。
Anyways my query is:
反正我的查询是:
ALTER TABLE "MYSCHEMA"."MYTABLE" ADD "ACOLUMN" CLOB(2048);
And get the following error:
并得到以下错误:
SQL Error: ORA-01735: invalid ALTER TABLE option
01735. 00000 - "invalid ALTER TABLE option"
Any ideas?
有任何想法吗?
Thanks.
谢谢。
回答by Vincent Malgrat
You can't specify a size for CLOB (use VARCHAR if you want to specify a size):
您不能为 CLOB 指定大小(如果要指定大小,请使用 VARCHAR):
SQL> alter table t add ("ACOLUMN" CLOB(2048));
alter table t add ("ACOLUMN" CLOB(2048))
ORA-00907: missing right parenthesis
SQL> alter table t add ("ACOLUMN" CLOB);
Table altered
回答by Michal Pravda
alter table t add a_column clob;
alter table t add a_column_with_max_size varchar2(1234); --max 4000
回答by Tony Andrews
If you never want more than 2048 characters in that column, don't use a CLOB, use VARCHAR2(2048). VARCHAR2 is good for up to 4000 characters; only use CLOB if you may need more than that.
如果您不想在该列中超过 2048 个字符,请不要使用 CLOB,而应使用 VARCHAR2(2048)。VARCHAR2 适用于最多 4000 个字符;如果您可能需要更多,请仅使用 CLOB。