Every SQL document contains the Text view with SQL editor in it. You switch to this view to edit your SQL queries.
When you type text in SQL editor, it automatically recognizes and highlights SQL syntax.
For ease of SQL writing and reviewing, you can also use such supported shortcut keys as:
You write and execute SQL queries not only one at a time but you may as well compose SQL scripts. SQL scripts consist of multiple SQL statements separated by the appropriate statement delimiter.
If you are using more than one language in your query, it is important to specify it in between two $ signs. This will help the parser to correctly identify it, as well as find the beginning and end of the procedure/function body. For example:
CREATE PROCEDURE insert_data(a integer, b integer)
LANGUAGE SQL
AS $sql$
INSERT INTO table VALUES (a);
INSERT INTO table VALUES (b);
$sql$;
CREATE FUNCTION public.function_name()
RETURNS INT
LANGUAGE plpgsql
AS $plpgsql$
BEGIN
RETURN NULL;
END;
$plpgsql$
$plpgsql$, $sql$ are not stored in a database but help dbForge Studio determine the language when reading an object from it. Therefore, you will not violate the compatibility of the code with other IDEs for PG by specifying the language.
Note
The procedure or function will also work correctly in PostgreSQL if you simply specify $$. dbForge Studio will highlight the entire body as a string. IntelliSense and code formatter will not work in this part of the query:
When writing SQL code, it is essential to include comments to enhance its readability and understandability for other developers who might need to work with it later.
To leave a comment in the SQL document:
Colorize the TODO comments, making them visually distinct from regular ones. In order to customize these comments:
To remove comment characters from the SQL document: