
If we look it up 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 a comparison.
sqlCopyEditSET var_Name = 'ALEXANDRE';
In the example above, we are assigning the literal ALEXANDRE to the variable var_Name. We can say that the content (or meaning) of var_Name is ALEXANDRE.
Ah! I get it!!! Everything between quotes is a literal. Not so fast. The analogy is good, but imperfect.
sqlCopyEditSET var_I_like_to_move_it_move_it = FALSE;
SET @var_Price = 10;
SET @Qtty = 3;
SET @Total = @var_Price * @Qtty;
FALSE (0) is a literal assigned to var_I_Like_To_Move_it_Move_it. Although my kids love Madagascar, and I like King Julian, I don’t like to dance. So, FALSE (0 in MySQL) describes the content of the variable to which it was assigned.
10 is the literal assigned to the integer variable @var_Price. Likewise, 3 tells the value of the variable @Qtty. The computation (calculation) of the literals contained in the environment variables @var_Price and @Qtty describes the environment variable @Total.
So, a literal can be of any type: characters (string), numbers, dates, booleans, or even binary.
sqlCopyEditSELECT * FROM tab_1 WHERE data_compra >= '2020-01-01';
The literal ‘2020-02-01’ was used to establish a comparison with the purchase date, making it possible to filter data from the tab_1 table.
Visit our Blog
Learn more about databases
Learn about monitoring with advanced tools

Have questions about our services? Visit our FAQ
Want to see how we’ve helped other companies? Check out what our clients say in these testimonials!
Discover the History of HTI Tecnologia