Programming Guide

DolphinDB scripting language and SQL reference

DolphinDB supports the following programming languages:

  • DolphinDB scripting language: A programming language used to interact with DolphinDB databases, featuring data types, data forms, objects, operators and their rules, programming statements, and functional programming. DolphinDB scripting language is case-sensitive. All identifiers—including variable, function, and class names—as well as reserved keywords must match case exactly.
  • SQL: DolphinDB is highly compatible with the ANSI-92 SQL standard and multiple mainstream SQL dialects. Understanding how SQL keywords are used in DolphinDB ensures a smooth transition for SQL users.

In DolphinDB, each line is treated as a complete statement by default, with the line break marking the end of the statement. However, certain syntax structures allow a single statement to span multiple lines to improve readability, such as long SQL queries or chained function calls.

  1. SQL Statements

    SQL queries in DolphinDB allow line breaks between keywords, following standard SQL conventions:

    select sym, qty, price
    from trades
    where date between 2024.01.01 and 2024.12.31
    context by sym
  2. Chained Function Calls

    Chained function calls can span multiple lines:

    data
    .cumsum()
    .max()
  3. Expressions inside ( ), [ ], or { }

    Expressions inside ( ), [ ], or { } can span multiple lines without using backslashes:

    sum = add(
      100,
      200
    )
    
    lags = ["A1",
    "A2","A3","A4",
    "A5","A6","A7",
    "A8","A9","A10"] 
    
    myMap = {
        "a": 1,
        "b": 2,
        "c": 3
    }
  4. Line Ends with an Incomplete Expression

    If a line ends with an operator or a comma, DolphinDB treats the statement as incomplete and continues parsing on the next line:

    a = 1 +
        2

    Note: If a line forms a complete statement and the next line begins with an operator, DolphinDB will parse them as two separate statements, resulting in a syntax error.

    a = 1
    + 2  // Syntax Error. "+ 2" is regarded as a separate statement.