Database Reference
In-Depth Information
There are situations where fully qualified names are required, as we see in later
chapters. For now, it is worth noting this syntax so you know what it is if you
run across it.
Using Comments
As you have seen, SQL statements are instructions processed by MariaDB.
But what if you wanted to include text that you do not want processed and
executed? Why would you ever want to do this? Here are a few reasons:
The SQL statements we've been using here are all short and simple.
But, as your SQL statements grow (in length and complexity), you'll
want to include descriptive comments (for your own future reference
or for whoever has to work on the project next). These comments
need to be embedded in the SQL scripts, but they are obviously not
intended for MariaDB processing. (For an example of this, see the
create.sql and populate.sql files used in Appendix B, “The
Example Tables.”)
The same is true for headers at the top of SQL files, perhaps contain-
ing the programmer contact information and a description and notes.
(This use case is also seen in the Appendix B .sql files.)
Another important use for comments is to temporarily stop SQL code
from being executed. If you were working with a long SQL statement,
and wanted to test just part of it, you could comment out some of the
code so that MariaDB saw it as comments and ignored it.
MariaDB supports several forms of comment syntax. We start with inline
comments:
Input
SELECT prod_name -- this is a comment
FROM products;
Analysis
Comments may be embedded inline using -- (two hyphens). Anything after
the -- is considered comment text, making this a good option for describing
columns in a CREATE TABLE statement, for example.
Here is another form of inline comment:
 
 
Search WWH ::




Custom Search