如何修复“ORA-00950:无效的 DROP 选项”?
ORA-00950:无效的降落选项
是我遇到的错误。我编写了此过程,以从EMP_1表中删除所有索引。那么,任何人都可以帮助我找出错误并解决此错误吗?
CREATE OR REPLACE NONEDITIONABLE PROCEDURE sp_drop_indexes (
p_table_name IN VARCHAR2,
p_errormsg OUT VARCHAR2 )
IS
v_sql VARCHAR2(1000);
CURSOR get_indexes IS
SELECT index_name
FROM user_indexes
WHERE table_name = 'EMP_1';
BEGIN
FOR rec IN get_indexes LOOP
v_sql := 'DROP INDEX' || rec.index_name;
EXECUTE IMMEDIATE v_sql;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
p_errormsg := sqlerrm;
END sp_drop_indexes;
ORA-00950: invalid DROP option
Above is the error that I am getting. I have written this procedure to remove all indexes from the emp_1 table. So can anyone please help me to find out the error and to fix this error?
CREATE OR REPLACE NONEDITIONABLE PROCEDURE sp_drop_indexes (
p_table_name IN VARCHAR2,
p_errormsg OUT VARCHAR2 )
IS
v_sql VARCHAR2(1000);
CURSOR get_indexes IS
SELECT index_name
FROM user_indexes
WHERE table_name = 'EMP_1';
BEGIN
FOR rec IN get_indexes LOOP
v_sql := 'DROP INDEX' || rec.index_name;
EXECUTE IMMEDIATE v_sql;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
p_errormsg := sqlerrm;
END sp_drop_indexes;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您在代码中的
DROP INDEX
之后缺少一个空格(但仍在引号内):You are missing a space after the
DROP INDEX
(but still inside the quotes) in your code:确保在
DROP INDEX
关键字后包含一个空格:Make sure you include a space after the
DROP INDEX
keyword:删除索引后需要一个空格,如果索引名称可以区分大小写,则需要双引号:
You need a space after drop index and, if you can have case-sensitive index names, you need double quotes: