Arquivo da categoria: Teoria de Banco de Dados

What are literals in MySQL?

If we look in the dictionary: literals are meanings. Description of something in the form of text. In MySQL, Oracle, SQL Server, or any other database, a literal is the content of a variable, or simply a value offered for comparison.

SET var_Name = ‘ALEXANDRE’

In the example above we’ve assigned the literal ALEXANDRE to the var_Name variable. We can say that the content (or meaning) of var_Name is ALEXANDRE.

Ah! Got it!!! Everything between quotes is a literal. Not so fast. The analogy is good but imperfect.

SET var_I_like_move_move_it  = FALSE;

SET @var_Price = 10;

SET @Qty = 3;

SET @Total = @var_Price * @Qty;

FALSE (0) is a literal that has been assigned to var_I_like_move_move_it.  Although my children love Madagascar, and, I being sympathetic to King Julien, I don’t like to dance. Therefore, FALSE (0 in MySQL) describes the contents of the variable to which it was assigned.

10 is the literal assigned to the integer variable @var_Price. Like, 3 tells me how much the @Qty variable is worth. The computation (calculation) of the literals contained in the environment variables @Var_Price and @Qty describe the environment variable @Total, or the value within the variable. Continue lendo What are literals in MySQL?