For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
  • Welcome
    • Overview
    • Release Notes
  • Installation and Configuration
    • System Requirements
    • Installation
    • Services and Utilities
    • Executor Resource Manager
    • Configuration Parameters
    • Security
    • Distributed Configuration
  • Loading and Exporting Data
    • Supported Data Sources
    • Command Line
  • SQL
    • Data Definition (DDL)
    • Data Manipulation (DML)
      • SQL Capabilities
        • ALTER SESSION SET
        • ALTER SYSTEM CLEAR
        • DELETE
        • EXPLAIN
        • INSERT
        • KILL QUERY
        • LIKELY/UNLIKELY
        • SELECT
        • SHOW
        • UPDATE
        • Arrays
        • Logical Operators and Expressions
        • Table Expression and Join Support
        • Type Casts
      • Geospatial Capabilities
      • Functions and Operators
      • System Table Functions
      • Window Functions
      • Reserved Words
      • SQL Extensions
      • HeavyIQ LLM_TRANSFORM
  • HeavyImmerse
    • Introduction to HeavyImmerse
    • Admin Portal
    • Control Panel
    • Working with Dashboards
    • Measures and Dimensions
    • Using Parameters
    • Using Filters
    • Using Cross-link
    • Color Consistency
    • Chart Animation
    • Multilayer Charts
    • SQL Editor
    • Customization
    • Joins (Beta)
    • Chart Types
    • Deprecated Charts
    • HeavyIQ SQL Notebook
  • HeavyIQ Conversational Analytics
    • HeavyIQ Overview
    • HeavyIQ Model Overview (HeavyLM)
  • HeavyRF
    • Introduction to HeavyRF
    • Getting Started
    • HeavyRF Table Functions
  • HeavyConnect
    • HeavyConnect Release Overview
    • Getting Started
    • Best Practices
    • Examples
    • Command Reference
    • Parquet Data Wrapper Reference
    • ODBC Data Wrapper Reference
    • Raster Data Wrapper Reference
  • HeavyML (BETA)
    • HeavyML Overview
    • Clustering Algorithms
    • Regression Algorithms
    • Principal Components Analysis
  • Python / Data Science
    • Data Science Foundation
    • JupyterLab Installation and Configuration
    • Using HEAVY.AI with JupyterLab
    • Python User-Defined Functions (UDFs) with RBC
    • Ibis
    • Interactive Data Exploration with Altair
    • Additional Examples
  • APIs and Interfaces
    • heavysql
    • Thrift
    • JDBC
    • ODBC
    • Vega
    • RJDBC
    • SQuirreL SQL
    • heavyai-connector
  • Tutorials and Demos
    • Loading Data
    • Using Heavy Immerse
    • Hello World
    • Creating a Kafka Streaming Application
    • Getting Started with Open Source
    • Try Vega
  • Troubleshooting and Special Topics
    • Vulkan Renderer
    • Optimizing
    • Known Issues and Limitations
    • Logs and Monitoring
    • Archived Release Notes
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Your Privacy Choices | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogoDocumentation
On this page
  • ORDER BY
  • Query Hints
  • Syntax
  • Cross-Database Queries
  • Example
SQLData Manipulation (DML)SQL Capabilities

SELECT

||View as Markdown|
Previous

LIKELY/UNLIKELY

Next

SHOW

The SELECT command returns a set of records from one or more tables.

1query:
2 | WITH withItem [ , withItem ]* query
3 | {
4 select
5 }
6 [ ORDER BY orderItem [, orderItem ]* ]
7 [ LIMIT [ start, ] { count | ALL } ]
8 [ OFFSET start { ROW | ROWS } ]
9
10withItem:
11 name
12 [ '(' column [, column ]* ')' ]
13 AS '(' query ')'
14
15orderItem:
16 expression [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ]
17
18select:
19 SELECT [ DISTINCT ] [/*+ hints */]
20 { * | projectItem [, projectItem ]* }
21 FROM tableExpression
22 [ WHERE booleanExpression ]
23 [ GROUP BY { groupItem [, groupItem ]* } ]
24 [ HAVING booleanExpression ]
25 [ WINDOW window_name AS ( window_definition ) [, ...] ]
26
27projectItem:
28 expression [ [ AS ] columnAlias ]
29 | tableAlias . *
30
31tableExpression:
32 tableReference [, tableReference ]*
33 | tableExpression [ ( LEFT ) [ OUTER ] ] JOIN tableExpression [ joinCondition ]
34
35joinCondition:
36 ON booleanExpression
37 | USING '(' column [, column ]* ')'
38
39tableReference:
40 tablePrimary
41 [ [ AS ] alias ]
42
43tablePrimary:
44 [ catalogName . ] tableName
45 | '(' query ')'
46
47groupItem:
48 expression
49 | '(' expression [, expression ]* ')'

For more information, see SELECT.

ORDER BY

  • Sort order defaults to ascending (ASC).
  • Sorts null values after non-null values by default in an ascending sort, before non-null values in a descending sort. For any query, you can use NULLS FIRST to sort null values to the top of the results or NULLS LAST to sort null values to the bottom of the results.
  • Allows you to use a positional reference to choose the sort column. For example, the command SELECT colA,colB FROM table1 ORDER BY 2 sorts the results on colB because it is in position 2.

Query Hints

HEAVY.AI provides various query hints for controlling the behavior of the query execution engine.

Syntax

1SELECT /*+ hint */ FROM ...;

SELECT hints must appear first, immediately after the SELECT statement; otherwise, the query fails.

By default, a hint is applied to the query step in which it is defined. If you have multiple SELECT clauses and define a query hint in one of those clauses, the hint is applied only to the specific query step; the rest of the query steps are unaffected. For example, applying the /* cpu_mode */ hint affects only the SELECT clause in which it exists.

You can define a hint to apply to all query steps by prepending g_ to the query hint. For example, if you define /*+ g_cpu_mode */, CPU execution is applied to all query steps.

HEAVY.AI supports the following query hints.

Marker
Key-Value pair

The marker hint type represents a Boolean flag.

HintDetailsExample
allow_loop_joinEnable loop joins.SELECT /*+ allow_loop_join */ ...
cpu_modeForce CPU execution mode.SELECT /*+ cpu_mode */ ...
columnar_outputEnable columnar output for the input query.SELECT /*+ columnar_output */ ...
disable_loop_joinDisable loop joins.SELECT /*+ disable_loop_join */ ...
dynamic_watchdogEnable dynamic watchdog.SELECT /*+ dynamic_watchdog */ ...
dynamic_watchdog_offDisable dynamic watchdog.SELECT /*+ dynamic_watchdog_off */ ...
force_baseline_hash_joinUse the baseline hash join scheme by skipping the perfect hash join scheme, which is used by default.SELECT /*+ force_baseline_hash_join */ ...
force_one_to_many_hash_joinDeploy a one-to-many hash join by skipping one-to-one hash join, which is used by default.SELECT /*+ force_one_to_many_hash_join */ ...
keep_resultAdd result set of the input query to the result set cache.SELECT /*+ keep_result */ ...
keep_table_function_resultAdd result set of the table function query to the result set cache.SELECT /*+ keep_table_function_result */ ...
overlaps_allow_gpu_buildUse GPU (if available) to build an overlaps join hash table. (CPU is used by default.)SELECT /*+ overlaps_allow_gpu_build */ ...
overlaps_no_cacheSkip adding an overlaps join hash table to the hash table cache.SELECT /*+ overlaps_no_cache */ ...
rowwise_outputEnable row-wise output for the input query.SELECT /*+ rowwise_output */ ...
watchdogEnable watchdog.SELECT /*+ watchdog */ ...
watchdog_offDisable watchdog.SELECT /*+ watchdog_off */ ...

Cross-Database Queries

In Release 6.4 and higher, you can run SELECT queries across tables in different databases on the same HEAVY.AI cluster without having to first connect to those databases. This enables more efficient storage and memory utilization by eliminating the need for table duplication across databases, and simplifies access to shared data and tables.

To execute queries against another database, you must have ACCESS privilege on that database, as well as SELECT privilege.

Example

Execute a join query involving a table in the current database and another table in the my_other_db database:

1SELECT name, saleamt, saledate FROM my_other_db.customers AS c, sales AS s
2 WHERE c.id = s.customerid;