SAP HANA SQL: Learn Basic Statements in 10 Minutes
โก Smart Summary
SAP HANA SQL is the main database language of the platform. It handles schema definition, data manipulation, access control, and session management, following the standard that makes SQL portable across relational databases.

Most RDBMS database uses SQL as database language, the reason of being popular is โ it is powerful, vendor independent and standardized. SAP HANA also supports SQL.
In SAP HANA, SQL is the main database language.
What is SAP HANA SQL?
SQL Stands for Structured Query Language. It is a Standard Language for communicating with Relational databases like Oracle, MySQL etc. SQL is used to store, retrieve and modify the data in the database.
By using SQL in SAP HANA, we can perform following job-
- Schema definition and use (CREATE SCHEMA).
- DML Statement (SELECT, UPDATE, INSERT).
- DDL Statement (CREATE, ALTER, DROP)
- DCL Statement (GRANT, REVOKE)
- System Management
- Session Management
- Transaction Management
Statements are executed from the SQL console of SAP HANA Studio, from a command line client, or from an application connecting over JDBC or ODBC. The language itself is identical in each case.
SQL Statement Categories in SAP HANA
Every statement belongs to one of a small number of families. Knowing which family a statement sits in predicts whether it can be rolled back and what authorisation it needs.
| Category | Full name | Typical statements | Purpose |
|---|---|---|---|
| DDL | Data Definition Language | CREATE, ALTER, DROP, RENAME | Defines and changes objects such as schemas, tables, and views |
| DML | Data Manipulation Language | SELECT, INSERT, UPDATE, DELETE, UPSERT | Reads and changes the rows held inside objects |
| DCL | Data Control Language | GRANT, REVOKE | Controls which user or role may perform which action |
| TCL | Transaction Control Language | COMMIT, ROLLBACK, SAVEPOINT | Confirms or discards a unit of work |
| Session | Session management | SET SCHEMA, CONNECT, SET TRANSACTION | Configures the current connection |
| System | System management | ALTER SYSTEM, monitoring views | Administers the database instance itself |
UPSERT is worth noting because it does not exist in every dialect. It inserts a row when the key is new and updates it when the key already exists, which removes a common two statement pattern.
Comment in SQL
We can add a comment to improve the readability and maintainability of SQL Statements. Comment can be put on SQL in two ways-
- Single Line Comment – Double Hyphens “–“. This is one line comment.
- Multiple Line Comment โ “/* */”.
All Commented text is ignored by SQL Parser.
-- This is a single line comment SELECT ELEMENT FROM DHK_SCHEMA.TABLE1; /* This is a multiple line comment. Everything between the markers is ignored by the SQL parser. */ SELECT COUNT(*) FROM DHK_SCHEMA.TABLE1;
Basic SQL Syntax Examples in SAP HANA
The statements below cover the everyday cycle of creating a schema, defining a table, loading rows, and reading them back. They run unchanged in the SQL console.
1) Create a schema. A schema owns the objects created inside it and is the first thing a new project needs.
CREATE SCHEMA DHK_SCHEMA; SET SCHEMA DHK_SCHEMA;
2) Create a column table. Column store is the default and the reason for HANA analytical speed. Row store is chosen only for small, write heavy tables.
CREATE COLUMN TABLE DHK_SCHEMA.EMPLOYEE ( EMP_ID INTEGER NOT NULL, EMP_NAME NVARCHAR(100), HIRE_DATE DATE, SALARY DECIMAL(10,2), PRIMARY KEY (EMP_ID) );
3) Insert and update rows. INSERT adds a row and UPDATE changes existing ones. Always pair an UPDATE with a WHERE clause unless every row really should change.
INSERT INTO DHK_SCHEMA.EMPLOYEE VALUES (1, 'Anita Sharma', '2026-01-15', 55000.00); UPDATE DHK_SCHEMA.EMPLOYEE SET SALARY = 60000.00 WHERE EMP_ID = 1;
4) Query the data. SELECT supports the familiar WHERE, GROUP BY, HAVING, and ORDER BY clauses.
SELECT EMP_NAME, SALARY FROM DHK_SCHEMA.EMPLOYEE WHERE SALARY > 50000 ORDER BY SALARY DESC;
5) Grant access and commit. DCL controls who may read the table, and COMMIT makes the work permanent.
GRANT SELECT ON DHK_SCHEMA.EMPLOYEE TO REPORT_USER; COMMIT;
Field level detail on each column definition is covered in SAP HANA data types, and the symbols used in the WHERE clause in SAP HANA operators.
SAP HANA SQL vs Standard SQL
SAP HANA follows the SQL standard closely, which is why an experienced developer is productive quickly. The differences that matter are additions rather than departures.
| Area | Standard SQL | SAP HANA SQL |
|---|---|---|
| Table storage | Row oriented by default | Column store by default, row store optional |
| Insert or update in one statement | MERGE, where supported | UPSERT, simpler syntax for the same result |
| Result set limit | Dialect specific | LIMIT with OFFSET, plus TOP |
| Procedural extension | Vendor specific | SQLScript, with table variables and parallel execution |
| Full text search | Usually an add on | Built in through TEXT and SHORTTEXT columns |
| Case sensitivity | Varies | Undelimited identifiers are upper cased, delimited ones keep their case |
The identifier rule causes the most surprises. Writing a table name in lower case without double quotes creates it in upper case, and later selecting it inside double quotes in lower case then fails to find it. The rules are set out in the data types and identifiers tutorial, with the wider platform covered in the SAP HANA tutorial series.
