SQL Code Blocks - <<sql>>

When providing an example of how to execute an SQL statementincluding its resultsyou can use the <<sql>> macro, which is an alias for <<code lang=sql>>. Using <<sql>> will generate a box containing the text within the tags, much like <<code>>, but with the addition of special highlighting of key words and values. Below is the syntax for using <<sql>>, followed by an example of its use:

Syntax

<<sql [inline={true|false}] [indent=L] [wrap={true|false}]>>
SQL code goes here
<</sql>>

Use indent to indent the lines on the left, replacing L with a number to indicate the indent level (see list indent levels). Use wrap to force the lines to wrap or not. The default is false, causing a horizontal scroll to appear when the text is too wide.

Example

When providing an example, perhaps an example of how to execute an SQL statementincluding its resultsyou can enter something like the follow:

<<sql inline=false>>
CREATE TABLE table1 
(id INT, col1 CHAR(20));
<</sql>>

The above will be displayed on the documentation page like this:

CREATE TABLE table1 
(id INT, col1 CHAR(20));

Notice that the reserved words, such as CREATE TABLE and the column data-types, are highlighted in a different color text. Notice also how the value for the data-type is in yet another color. Notice also that the non-reserved words, the names of the table and column names, are in the default color. All of this combined makes it easier for the reader to distinguish between what they should enter on their server and what they should modify to their naming preference. Incidentally, as a convention, put reserve words in upper-case letters.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.