oracle SQL plus如何在SQL文件中结束命令? [英] oracle SQL plus how to end command in SQL file?

查看:476
本文介绍了oracle SQL plus如何在SQL文件中结束命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个命令的SQL文件.
在脚本中结束行的正确方法是什么?
是否同时使用[/]分号[;]?
常规sql和存储过程代码之间是否有区别?
谢谢

解决方案

对于普通的SQL语句,单独在一行上的/或命令末尾的;都可以正常工作. /p>

对于包含PL/SQL代码的语句,例如CREATE FUNCTIONCREATE PROCEDURECREATE PACKAGECREATE TYPE或匿名块(DECLARE/BEGIN/END),不会执行命令.由于PL/SQL使用分号作为行终止符,因此在这些语句中必须禁止将其用作命令终止符.因此,在这些情况下,必须使用/执行命令.

根据我的经验,人们更喜欢在可能的情况下使用分号,而仅在需要时才使用斜杠.

请注意,对于SQLPlus客户端命令(例如SETEXECUTE),根本不需要命令终止符,尽管人们经常出于习惯而以分号结尾.

I have SQL file with few commands.
What it the correct way to end lines in the script?
Is it slash [/] semicolon [;] both?
Is there any diffarent between regular sqls and Stored procedure code?
Thank you

解决方案

For normal SQL statements, either a / on a line by itself, or a ; at the end of the command, will work fine.

For statements that include PL/SQL code, such as CREATE FUNCTION, CREATE PROCEDURE, CREATE PACKAGE, CREATE TYPE, or anonymous blocks (DECLARE/BEGIN/END), a ; will not execute the command. Since PL/SQL uses semicolons as line terminators, its use as a command terminator must be suppressed in these statements. So in these cases, you must use / to execute the command.

In my experience, people prefer to use the semicolon when possible and use the slash only when required.

Note that for SQLPlus client commands -- such as SET or EXECUTE -- no command terminator is necessary at all, although people often end them with a semicolon out of habit.

这篇关于oracle SQL plus如何在SQL文件中结束命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆