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?
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With