For example, if your customer comes to your house, your mother will give you two yuan to buy a bottle of beer at the store for the guests to drink. As a result, the guests were not enough to drink, and your mom was afraid of waste. I gave you two yuan to let you go downstairs and buy another bottle. The result was not enough. I asked you to go downstairs and buy another bottle, let you buy another bottle ...... What do you say at this time? You will be impatient to answer: Mom, please, don't let me buy one bottle at a time, just a few more bottles at a time?
The same is true for SQL statements. Because SQL Server is a network database, a server may have many remote clients. If one SQL statement is sent at a time on the client, the client returns the result; then, an SQL statement is sent and then returned, which is too inefficient. To improve efficiency, SQL Server introduces the concept of batch processing.
Q batch processing is a group that contains one or more SQL statements, which are sent from an application to SQL Server for execution at a time.
Q SQL Server compiles batch processing statements into an executable unit, which is called an execution plan. Execute one statement in the execution plan each time
Select * From stuinfo
Select * From stumarks
Update stumarks
Set writtenexam = writtenexam + 2
Go
L go is a sign of batch processing, indicating that SQL Server compiles these T-SQL statements into an execution unit to improve execution efficiency
L generally, some logic-related business operation statements are placed in the same batch, which is completely determined by the business requirements and code writers.
L rules: if it is a database creation, table creation statement, and stored procedures and views that we will learn later, you must add the go batch processing mark at the end of the statement.