为什么要在sybase中使用GO命令?

发布于 2024-12-15 14:52:49 字数 270 浏览 0 评论 0原文

为sybase编写sql时为什么要使用GO?在我的项目现有的大多数 sql 中,没有 GO,但是当生成用于创建表的 DDL 时,例如,应用程序会插入许多 GO 语句。

感谢这些答案,我了解到 GO 与其他数据库中的 ; 类似,正如人们指出的那样,它是一个分隔符。

还有一个问题,sybase 中的 GO 与 Oracle 中的 ; 完全相同吗?

Why should I use GO when writing sql for sybase? In most of the existing sql my project has, there are no GOs but when DDL is generated for table creation, as an example, the application inserts many GO statements.

Thanks to the answers, I understand that GO is similar to ; in other databases, as people have helpfully pointed out it is a Delimiter.

An added question then, is GO in sybase exactly equivalent to typing ; in Oracle?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

溇涏 2024-12-22 14:52:49

这是一个批次分隔符。 GO 用于告诉引擎将单词 GO 之后的所有内容作为一个新命令批量处理。

CREATE PROC usp_blah as ...
GO

CREATE some-otherproc as ...
GO

如果没有 GO,优化器会在第二个 CREATE 语句处抛出错误

It's a batch separator. GO is used to tell the engine to process everything after the word GO as a new command in a batch.

CREATE PROC usp_blah as ...
GO

CREATE some-otherproc as ...
GO

Without GO, the optimizer would throw an error at the second CREATE statement

江南烟雨〆相思醉 2024-12-22 14:52:49

比较:

    Do something
    GO
    Do something else
    Go

如果

    Do something
    Do something else

在第一个示例中“执行某些操作”期间出现错误,则“执行其他操作”仍将运行。第二个示例中的情况并非如此。正如 Stuart 指出的那样,有些操作必须是批处理的第一个语句,这意味着您必须将 GO 放在它们之前,除非它们是文件的第一行。

Compare:

    Do something
    GO
    Do something else
    Go

To:

    Do something
    Do something else

If there is an error during 'Do something' in the first example then 'Do something else' will still run. This is not the case in the second example. And as Stuart pointed out there are some actions that require have to be the first statement of a batch, meaning you have to place GO before them unless the are the first line of your file.

不及他 2024-12-22 14:52:49

GO 是 SQL 分隔符

作业命令文本中出现的任何 [gG][oO] 都被视为批处理分隔符 go

GO is a SQL Delimiter

Any occurrence of [gG][oO] in the text of a job command is seen as the batch delimiter go.

梦在深巷 2024-12-22 14:52:49

所谓的分隔符 go 不是 SAP/Sybase Transact-SQL 语言语法的任何部分。

它通常被认为是一个批处理定界符,用于将一堆 T-SQL 语句与下一条语句分开。

由于所有 SAP/Sybase 批处理脚本都是使用本机 isql 命令行客户端执行的,因此 isql 客户端将 go 解释为将迄今为止在其缓冲区中输入的所有 T-SQL 命令通过服务器客户端提交到 ASE 服务器的信号用户网络连接(go不会出现在网络跟踪中,它不会发送到服务器)。

顺便说一句,isql 只能识别小写字母,并且后面不包含任何空格。

The so-called delimiter go isn't any of part of SAP/Sybase Transact-SQL language syntax.

It is commonly being thought of as a batch delimiter to separate a bunch of T-SQL statements from the next.

Since all SAP/Sybase batch scripts are executed using the native isql command line client, go is being interpreted by the isql client as a signal to submit all T-SQL commands entered in its buffer so far to the ASE server over the Server-Client user network connection (go does not appear in the network trace, it is not sent to the server).

Incidentally, isql would only recognise go in lower case only and not proceeded by any white spaces.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文