The <<sql>> Macro

You are viewing an old version of this article. View the current version here.

Syntax

<<sql [inline={true|false}] [indent=L] [wrap={true|false}]>>
SQL code goes here
<</sql>>
  • For indent, replace L with the indent level you want (corresponds to list indent levels)
  • For wrap, you can force the lines to wrap or not. The default is for code blocks to scroll.

About

Highlight and format SQL code.

This is a shortcut for <<code lang=sql>>. It also applies an additional style to aid in formatting the whole block.

Examples

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.