gsql/ Running GSQL
Last Updated: October 20, 2018Mastering the GSQL shell, interactive modes, and command execution.
Running GSQL
GSQL provides several modes of execution, ranging from an interactive shell to automated command files.
Language Basics
- Identifiers: Case-sensitive names for variables and types. Must start with a letter or underscore (no leading digits).
- Keywords: Semantic words like
VERTEXorEDGE. These are not case-sensitive but are often reserved. - Comments:
- Single-line:
#or// - Multi-line:
/* ... */
- Single-line:
The GSQL Shell
Enter the shell by typing gsql in your terminal.
Authentication
bashterminal# Standard login (defaults to tigergraph user) $ gsql -u <username> -p <password> # Token-based login (Modern/Recommended) $ gsql -t <token_value>
Multi-Line Mode
In the interactive shell, use BEGIN and END to wrap multi-line statements:
gsqlterminalGSQL > BEGIN GSQL > SELECT member_id, last_name GSQL > FROM Member GSQL > WHERE age >= 21 GSQL > END
Running Scripts
You can automate GSQL by saving commands in a .gsql file.
Execution Methods:
- From Linux Shell:
bashterminal
$ gsql my_script.gsql - Inline Commands:
bashterminal
$ gsql 'RUN QUERY my_query(10)' - Inside GSQL Shell:
gsqlterminal
GSQL > @my_script.gsql
Essential Catalog Commands
ls: Displays the entire catalog (Vertex types, Edge types, Graphs, Jobs, Queries).SHOW [VERTEX|EDGE|GRAPH] <name>: Displays detailed properties of a specific component.SET exit_on_error = FALSE: Allows a script to continue even if a semantic error occurs.
System Reset
Caution: The --reset option erases all data, schemas, and definitions.
bashterminal$ gsql --reset