What Does the "@" Symbol Do in SQL

What does the @ symbol do in SQL?

The @CustID means it's a parameter that you will supply a value for later in your code. This is the best way of protecting against SQL injection. Create your query using parameters, rather than concatenating strings and variables. The database engine puts the parameter value into where the placeholder is, and there is zero chance for SQL injection.

SQL Server : what does the '@@' symbol do?

local variables which begins with single @ prefix, The scope of a variable is the range of Transact-SQL statements that can reference the variable. The scope of a variable lasts from the point it is declared until the end of the batch or stored procedure in which it is declared.

Global variables which begins with @@ prefix, you do not need to declare them, since the server constantly maintains them, they are system-defined functions not variables and do not have the same behaviors as variables. All the global variables represent information specific to the server or a current user sessions. Some of the commonly used ones are @@ERROR, @@IDENTITY, @@VERSION.

Update:
Declaring any variable with @@ prefix (except the system-defined) is actually a local variable.

Meaning of the Symbol @@ in SQL Server

In SQL Server, symbol @@ is prefixed to global variables.

The server maintains all the global variables. We cannot declare them.

SQL $ symbol usage

There's no special functionality to the $ character.

The v$ views are public synonyms of Oracle's dynamic performance views. They are given these "unconventional" names to make them easy to recognize.

What is the meaning of '@' symbol in Oracle SQL?

It refers to a non-local table, the bit behind the @ is the db descriptor.

select * from question_answer@abcd where id = '45'

Means select not from the local question_answer table, but from the table on the db designated as abcd. The keyword to google for is dblink

What does the @ symbol means on a Procedure in MySQL?

The @ makes it a user defined session variable. Otherwise it would be locally scoped variable (in a stored procedure), you would have to DEFINE your local before you can SET it. You could also set a global system variable (with SET GLOBAL or SET @@global) if you wanted to. As well as a session system variable with SET SESSION var or SET @@session var or SET @@var.

More details about SET from the documentation: If no modifier is present, SET changes the session variable (that's why you DEFINE your locals in the stored procedure first). If you set several system variables, the most recent GLOBAL or SESSION modifier in the statement is used for following variables that have no modifier specified.

More (and some good examples) here:

  • MySQL: @variable vs. variable. Whats the difference?
  • Variables in Stored Programs


Related Topics



Leave a reply



Submit