删除全局临时表
2 单独的问题。
我正在使用此脚本删除表[已解决]
<前><代码>开始 立即执行“删除表名称”; DBMS_OUTPUT.PUT_LINE('全局表TABLE_NAME已删除'); 例外 当其他人 DBMS_OUTPUT.PUT_LINE('全局表 TABLE_NAME 不存在。'); 结尾; /
无论如何,我是否可以区分表“不存在”或它正在其他一些会话中使用(在这种情况下,它将被锁定)并且无法删除)。我不确定是否可以看到 user_tables 中存在该表。我不完全了解权限。
我现在添加了这段代码
WHEN OTHERS THEN
i_code := SQLCODE;
v_errm := SUBSTR(SQLERRM, 1, 64);
if i_code = -942 THEN
DBMS_OUTPUT.PUT_LINE ('TABLE_NAME doesn''t exist. Script will continue to create it');
ELSE
DBMS_OUTPUT.PUT_LINE ('Error dropping temporary table. The error code is ' || i_code || '- ' || v_errm);
END IF ;
2。我在每个过程的末尾看到.,这样
END PROCEDURE_NAME;
.
/
sho err;
我只是不明白为什么.在这里。是语法还是什么?
2 Separate questions.
I am using this script to drop a table [SOLVED]
BEGIN EXECUTE IMMEDIATE 'DROP TABLE_NAME'; DBMS_OUTPUT.PUT_LINE ('Global table TABLE_NAME Dropped'); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE ('Global table TABLE_NAME Doesn''t exist.'); END; /
Is there anyway I can differentiate if table "doesn't exist" or it is being used in some other sessions (in that case it would locked and couldn't be deleted). I am not sure if I can see that table exists in user_tables. I am not fully aware of permissions.
I have added this code now
WHEN OTHERS THEN
i_code := SQLCODE;
v_errm := SUBSTR(SQLERRM, 1, 64);
if i_code = -942 THEN
DBMS_OUTPUT.PUT_LINE ('TABLE_NAME doesn''t exist. Script will continue to create it');
ELSE
DBMS_OUTPUT.PUT_LINE ('Error dropping temporary table. The error code is ' || i_code || '- ' || v_errm);
END IF ;
2. I see . at the end of each procedure like this
END PROCEDURE_NAME;
.
/
sho err;
I just don't understand why . is here. Is it syntax or what?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
DECLARE GLOBAL TEMPORARY TABLE 语句为当前连接定义临时表。
这些表不驻留在系统目录中并且不是持久的。
临时表仅在声明它们的连接期间存在,并且不能在该连接之外引用。
当连接关闭时,表中的行将被删除,临时表的内存中描述也将被删除。
供您参考http://docs.oracle.com/javadb/10.6。 2.1/ref/rrefdeclaretemptable.html
The DECLARE GLOBAL TEMPORARY TABLE statement defines a temporary table for the current connection.
These tables do not reside in the system catalogs and are not persistent.
Temporary tables exist only during the connection that declared them and cannot be referenced outside of that connection.
When the connection closes, the rows of the table are deleted, and the in-memory description of the temporary table is dropped.
For your reference http://docs.oracle.com/javadb/10.6.2.1/ref/rrefdeclaretemptable.html
putty
中运行来关闭 apache 服务器cd $ADMIN_SCRIPTS_HOME
./adstpall.sh
drop table t;
这将锻炼..
putty
cd $ADMIN_SCRIPTS_HOME
./adstpall.sh
drop table t;
This will workout..
步骤 1. 确定要捕获哪些错误:
如果表不存在:
如果表正在使用:
在另一个会话中使用该表。 (注意插入后没有提交或任何内容。)
回到第一个会话,尝试删除:
因此要捕获两个错误:
在已使用的临时表上创建、更改或删除索引
查看错误是否为 预定义。他们不是。因此,它们需要像这样定义:
结果,首先没有
t
:现在,使用
t
:在另一个会话中:
然后在第一个会话中:
Step 1. Figure out which errors you want to trap:
If the table does not exist:
If the table is in use:
Use the table in another session. (Notice no commit or anything after the insert.)
Back in the first session, attempt to drop:
So the two errors to trap:
create, alter or drop an index on temporary table already in use
See if the errors are predefined. They aren't. So they need to be defined like so:
And results, first without
t
:And now, with
t
in use:In another session:
And then in the first session:
是的 - 引擎将针对不同的条件抛出不同的异常。
您将更改此部分以捕获异常并执行不同的操作,
这里是参考
http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/07_errs.htm
yes - the engine will throw different exceptions for different conditions.
you will change this part to catch the exception and do something different
here is a reference
http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/07_errs.htm