错误报告 - ORA -00969:创建索引时关键字上缺少
我想在Oracle表上创建多个索引,其中包含这些列trx_date,customer_id,time_stamp,time_stamp,用户名,密码,地址
使用此查询:
declare
type rtype is table of varchar(50);
cols rtype := rtype('time_stamp', 'trx_date',concat('TRX_DATE'||'-'||'CUSTOMER_ID') ,'trx_time');
t_name varchar(100) := upper('test');
table_space varchar(100) := 'users';
col varchar(50);
ix_name varchar(50);
begin
for j in 1..cols.count loop
col := cols(j);
ix_name := col || '123_ix';
execute immediate 'create index ' || ix_name || ' ON ' || t_name || '(' || col || ') local unusable';
for i in (select partition_name from user_tab_partitions where table_name=t_name) loop
execute immediate 'alter index ' || ix_name || ' rebuild partition ' || i.partition_name || ' tablespace ' || table_space || ' parallel(degree 2)';
end loop;
end loop;
end;
当我运行上述查询时,我会收到此错误
Error report -
ORA-00969: missing ON keyword
ORA-06512: at line 12
00969. 00000 - "missing ON keyword"
*Cause:
*Action:
:当我将该查询更改为此时:
declare
type rtype is table of varchar(50);
cols rtype := rtype('time_stamp', 'trx_date','TRX_DATE'||'CUSTOMER_ID' ,'trx_time');
t_name varchar(100) := upper('test');
table_space varchar(100) := 'users';
col varchar(50);
ix_name varchar(50);
begin
for j in 1..cols.count loop
col := cols(j);
ix_name := col || '123_ix';
execute immediate 'create index ' || ix_name || ' ON ' || t_name || '(' || col || ') local unusable';
for i in (select partition_name from user_tab_partitions where table_name=t_name)
循环 立即执行“ Alter Index” || ix_name || “重建分区” || i.partition_name || '表空间'|| table_space || “平行(2度)”; 结束循环; 结束循环; 结尾;
运行上述查询时,会收到此错误:
Error report -
ORA-00904: "TRX_DATECUSTOMER_ID": invalid identifier
ORA-06512: at line 12
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
您能指导我如何解决该查询吗?
任何帮助都非常感谢。
I want to create several index on the Oracle table which has these columns TRX_DATE,CUSTOMER_ID,time_stamp,username,password,address
using this query:
declare
type rtype is table of varchar(50);
cols rtype := rtype('time_stamp', 'trx_date',concat('TRX_DATE'||'-'||'CUSTOMER_ID') ,'trx_time');
t_name varchar(100) := upper('test');
table_space varchar(100) := 'users';
col varchar(50);
ix_name varchar(50);
begin
for j in 1..cols.count loop
col := cols(j);
ix_name := col || '123_ix';
execute immediate 'create index ' || ix_name || ' ON ' || t_name || '(' || col || ') local unusable';
for i in (select partition_name from user_tab_partitions where table_name=t_name) loop
execute immediate 'alter index ' || ix_name || ' rebuild partition ' || i.partition_name || ' tablespace ' || table_space || ' parallel(degree 2)';
end loop;
end loop;
end;
When I run the above query, I receive this error:
Error report -
ORA-00969: missing ON keyword
ORA-06512: at line 12
00969. 00000 - "missing ON keyword"
*Cause:
*Action:
Moreover, when I change that query to this one:
declare
type rtype is table of varchar(50);
cols rtype := rtype('time_stamp', 'trx_date','TRX_DATE'||'CUSTOMER_ID' ,'trx_time');
t_name varchar(100) := upper('test');
table_space varchar(100) := 'users';
col varchar(50);
ix_name varchar(50);
begin
for j in 1..cols.count loop
col := cols(j);
ix_name := col || '123_ix';
execute immediate 'create index ' || ix_name || ' ON ' || t_name || '(' || col || ') local unusable';
for i in (select partition_name from user_tab_partitions where table_name=t_name)
loop
execute immediate 'alter index ' || ix_name || ' rebuild partition ' || i.partition_name || ' tablespace ' || table_space || ' parallel(degree 2)';
end loop;
end loop;
end;
When run the above query,receive this error:
Error report -
ORA-00904: "TRX_DATECUSTOMER_ID": invalid identifier
ORA-06512: at line 12
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Would you please guide me how to solve that query?
Any help is really appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您太乐观了,执行语句您没有验证。因此:首先撰写语句, display 它(以便您可以看到实际要做的事情),然后 - 一旦它被列出,就可以执行它(而不是显示)。
哪些导致
有任何可疑的东西?我愿意,以索引名称为单位 minus 签名。我会用下划线代替它。
另外,
concat
仅接受两个参数 - 使用双管(就像我一样)。You're being too optimistic, executing statement you didn't verify. Therefore: compose the statement first, display it (so that you could see what you're actually trying to do) and then - once it is verfied - execute it (instead of displaying it).
which results in
See anything suspicious? I do, a minus sign in index name. I'd substitute it with an underline.
Also,
CONCAT
accepts only two parameters - use double pipe instead (just like I did).