Search code examples
sqlt-sqlsap-ase

Why should I use GO command in sybase?


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?


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