为什么要在sybase中使用GO命令?
为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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是一个批次分隔符。
GO
用于告诉引擎将单词GO
之后的所有内容作为一个新命令批量处理。如果没有
GO
,优化器会在第二个CREATE
语句处抛出错误It's a batch separator.
GO
is used to tell the engine to process everything after the wordGO
as a new command in a batch.Without
GO
, the optimizer would throw an error at the secondCREATE
statement比较:
如果
在第一个示例中“执行某些操作”期间出现错误,则“执行其他操作”仍将运行。第二个示例中的情况并非如此。正如 Stuart 指出的那样,有些操作必须是批处理的第一个语句,这意味着您必须将 GO 放在它们之前,除非它们是文件的第一行。
Compare:
To:
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.
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
.所谓的分隔符 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.