Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

GO is a SQL Delimiter

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top