美文网首页数据库相关
oracle 在linux上发布存储过程

oracle 在linux上发布存储过程

作者: 仔仔H | 来源:发表于2020-04-03 10:33 被阅读0次

当你不能用plsql等图形工具连接oracle数据库时,怎么发布存储过程呢?

第一步,备份以前的程序。如果以前有程序文本文件的,直接备份文件,没有的,那就直接连sqlplus去查。
连接sqlplus语法:sqlplus 用户名/密码@数据库ip:端口号/数据库名称
例如:sqlplus DH_BI/a123456@oracledb
查询存储过程语法:用user_source或者all_source都可以。
select text from user_source where name = '存储过程名' order by line;
例如: select text from user_source where name = 'PRO_STUDENT' order by line;
select text from all_source where name = '存储过程名' and OWNER='用户名' order by line;
例如: select text from all_source where name = 'PRO_STUDENT' and OWNER='DH_BI' order by line;

第二步:发布存储过程。
直接粘贴上去,回车,如果没有结束,再输入 '/',再回车。会提示过程已创建,或者英文提示,成功或失败。失败再检查是否语法有问题,测试环境一样吗,表结构一样吗。


image.png

另外:
存储过程样例:

create or replace procedure pro_test is
begin
  dbms_output.put_line('this is a test for procedure');
end pro_test;

删除存储过程语法:drop procedure 存储过程名;
例如: drop procedure pro_test;

执行存储过程:

SQL> execute pro_test;
this is a test for procedure

PL/SQL 过程已成功完成。

sqlplus直接执行sql文本
先把SQL文本放到你连接的数据库的那个电脑或服务器上,比如路径:/data/test.sql ,内容:select 'this is a text' as text from dual;
连接sqlplus后直接在输入框中输入:@/data/test.sql


image.png

参考自:http://blog.chinaunix.net/uid-31094491-id-5709769.html

相关文章

网友评论

    本文标题:oracle 在linux上发布存储过程

    本文链接:https://www.haomeiwen.com/subject/onicphtx.html