---
title: "Learn SAP HANA: Commonly Used SQL Statements"
description: Take a look at some of the commonly used SQL statements that help to define SAP HANA tables, including SET SCHEMA and CREATE SCHEMA.
image: https://blog.sap-press.com/hubfs/Learn%20SAP%20HANA%20Commonly-Used%20SQL%20Statements.png
---

[![rheinwerk-sappress-logo-header-1](https://blog.sap-press.com/hubfs/rheinwerk-sappress-logo-header-1.svg)](https://blog.sap-press.com/) [Blog](https://blog.sap-press.com)

- Books 
    - Get an overview of our books and courses on every relevant SAP topic. 
          - [Programming](https://sap-press.com/programming/)
          - [Administration](https://sap-press.com/administration/)
          - [BI](https://sap-press.com/business-intelligence/)
          - [Finance](https://sap-press.com/finance-controlling/)
          - [Logistics](https://sap-press.com/logistics/)
          - [HR](https://sap-press.com/human-resources/)
          - [CRM & Sales](https://sap-press.com/marketing-sales/)
          - [HANA](https://sap-press.com/hana/)
          - [Introductions](https://sap-press.com/introductions/)
          - [E-Bites](https://sap-press.com/e-bites/)
          - [Certification Guides](https://www.sap-press.com/certification-guides/)
          - [Rheinwerk Courses](https://www.sap-press.com/online-courses/)
- Book Subscription 
    - Get unlimited access to all SAP PRESS books! 
          - [SAP PRESS Subscription](https://sap-press.com/subscriptions/)

[SAP HANA](https://blog.sap-press.com/tag/sap-hana)

# Learn SAP HANA: Commonly Used SQL Statements

![SAP PRESS](https://blog.sap-press.com/hubfs/Twitter_profile_pic.svg)  by [SAP PRESS](https://blog.sap-press.com/author/sap-press)

Let’s discuss some of the commonly used SQL statements to define [SAP HANA](https://learning.sap-press.com/sap-hana) tables.

 

## CREATE SCHEMA

CREATE SCHEMA creates a new schema in the database. The syntax for this statement is as follows:

 

CREATE SCHEMA \<schema\_name\> \[OWNED BY \<user\_name\>\]

 

In this syntax, \<schema\_name\> specifies the schema name, and \<user\_name\> specifies the name of the schema owner. If \<user\_name\> is omitted, the current user is the owner of the schema. An example of this syntax in action is as follows:

 

CREATE SCHEMA CHICKEN\_WINGS;

 

## SET SCHEMA

SET SCHEMA changes the current schema for the session. When schema is set for a session, objects in the specified schema (i.e., tables, views, etc.) can be referenced without the schema name. Objects in other schemas have to be referenced with the schema name, for example, MY\_SCHEMA.MY\_TABLE. The syntax for this statement is as follows:

 

SET SCHEMA \<schema\_name\>

 

In this syntax, \<schema\_name\> specifies the name of the schema. An example of this syntax in action is as follows:

 

SET SCHEMA CHICKEN\_WINGS;

 

## CREATE TABLE

CREATE TABLE creates a new table in the database. The syntax for this statement, in its simplest form, is as follows:

 

CREATE \[\<table\_type\>\] TABLE \<table\_name\> (

\<column\_name\> \<data\_type\>,

\<column\_name\> \<data\_type\>,...

PRIMARY KEY (\<column\_name\>,\<column\_name\>..))

 

In this syntax, \<table\_type\> defines the type of table storage organization such as COLUMN, ROW, HISTORY COLUMN, and so on. The default value is ROW. We’ll be using COLUMN tables for defining our data model.

 

In addition, \<table\_name\> and \<column\_name\> specify the name of the table and columns to be created, respectively. The \<table name\> and \<column\_name\> attributes are case sensitive if specified using double quotes (e.g., “Airport” instead of Airport).

 

Next, \<data\_type\> specifies the data type of the columns in the table. Commonly used data types are INTEGER, NVARCHAR(x), DECIMAL(p,s), DATE, TIME, and so on. Refer to the SAP HANA SQL and System Views Reference guide for a complete list of supported data types. An example of this syntax in action is as follows:

 

CREATE COLUMN TABLE AIRPORT (

CODE NVARCHAR(3),

NAME NVARCHAR(50),

CITY NVARCHAR(20),

PRIMARY KEY (CODE));

 

[Learn more about creating a table with SQLScript here](https://blog.rheinwerk-computing.com/how-to-create-a-database-table-with-sqlscript).

 

## COMMENT ON

COMMENT ON adds or removes a comment to an object in the database. The syntax for this statement is as follows:

 

COMMENT ON \<object\_type\> \<object\_name\> IS \<comment\>

 

In this syntax, \<object\_type\> specifies the type of object, that is, table, view, or column; \<object\_name\> specifies the name of the object to add the comment to; and \<comment\> specifies the comment itself. If NULL is specified, then any existing comment is dropped. An example of this syntax in action is as follows:

 

-- Comment on 'Airport' Table

COMMENT ON TABLE AIRPORT is 'Airport Details';

-- Comment on 'CODE' Column of 'AIRPORT' table

COMMENT ON COLUMN AIRPORT.CODE is 'Airport IATA Code';

 

## ALTER TABLE

ALTER TABLE alters the definition of a table, that is, to add/drop table columns, create/ drop constraints such as foreign keys, and so on. The syntax to add a foreign key constraint is as follows:

 

ALTER TABLE \<table\_name\> ADD CONSTRAINT \<constraint\_name\>

 

FOREIGN KEY

(\<referencing\_column\_name\> \[{,\<referencing\_column\_name\>}...\])

REFERENCE (\<table\_name\>(\<referenced\_column\_name\>\[{,\<referenced \_column\_

name\>}...\]);

 

An example of this syntax in action is as follows:

 

-- AIRPORT.CODE is referenced from CONNECTION.FROMAP column

ALTER TABLE CONNECTION ADD CONSTRAINT FK\_CONNECTION\_AIRPORT\_FROM

FOREIGN KEY (FROMAP) REFERENCES AIRPORT(CODE)

 

## INSERT INTO

INSERT INTO adds a record to a table, and the syntax is as follows:

 

INSERT INTO \<table\_name\> \[\<column\_list\>\] VALUES (

\<column\_value\>, \<column\_value\>, ...)

 

In this syntax, the optional \<column\_list\> specifies the list of columns for which values are provided. If \<column\_list\> isn’t provided, values must be provided for all columns. In addition, \<column\_value\> specifies the value for each column.

 

An example of this syntax in action is as follows:

 

INSERT INTO AIRPORT VALUES ('YYZ','Lester B. Pearson International',

'Toronto','CANADA','EST',43.677718,-79.624820);

 

## SELECT

SELECT retrieves information from the database table, and the syntax in its simplest form is as follows:

 

SELECT \<column\_name\> \[,column\_name, column\_name\] FROM \<table\_name\>;

 

In this syntax, \<column\_name\> specifies the list of columns to retrieve data from the \<table\_name\> table. An example of this syntax in action is as follows:

 

-- Retrieves data for all columns

SELECT \* FROM AIRPORT;

-- Retrieves data for selected columns

SELECT CODE, NAME, CITY, COUNTRY FROM AIRPORT;

 

## Conclusion

These are just a few of the commonly used SQL statements to define SAP HANA tables. You will need to have a full understanding of these statements to do well on [SAP certifications](https://learning.sap-press.com/sap-certifications) such as the [SAP HANA Application Associate Certification exam](https://blog.sap-press.com/learn-sap-hana-what-is-the-sap-hana-application-associate-certification-exam). Refer to SAP HANA SQL and System Views Reference guide ([*https://bit.ly/2sR5K4u*](https://bit.ly/2sR5K4u)) for the complete list of SQL statements supported by SAP HANA.

 

Editor’s note: This post has been adapted from a section of the book *[SAP HANA XSA: Native Development for SAP HANA](https://www.sap-press.com/sap-hana-xsa_4500?utm_source=sappressblog&utm_medium=referral&utm_campaign=Blogs&utm_term=chapter5&utm_content=1601)* by Francesco Alborghetti, Jonas Kohlbrenner, Abani Pattanayak, Dominik Schrank, and Primo Sboarina.

## Recommendation

[![SQLScript for SAP HANA](https://blog.sap-press.com/hs-fs/hubfs/2139.jpg?width=170&name=2139.jpg)](https://www.sap-press.com/sqlscript-for-sap-hana_5336/?utm_source=sappressblog&utm_medium=referral&utm_campaign=Blogs&utm_term=1601_chapter5&utm_content=2139)

**SQLScript for SAP HANA**

New to SQLScript—or maybe looking to brush up on a specific task? Whatever your skill level, this comprehensive guide to SQLScript for SAP HANA is for you! Master language elements, data types, and the function library. Learn to implement SAP HANA database procedures and functions using imperative and declarative SQLScript. Integrate with ABAP, SAP BW on SAP HANA, and SAP BW/4HANA. Finally, test, troubleshoot, and analyze your SQLScript programs. Code like the pros!

[Learn More](https://www.sap-press.com/sqlscript-for-sap-hana_5336/?utm_source=sappressblog&utm_medium=referral&utm_campaign=Blogs&utm_term=1601_chapter5&utm_content=2139)

![SAP PRESS](https://blog.sap-press.com/hubfs/Twitter_profile_pic.svg)

**by [SAP PRESS](https://blog.sap-press.com/author/sap-press)**

SAP PRESS is the world's leading SAP publisher, with books on ABAP, SAP S/4HANA, SAP IBP, intelligent technologies, SAP Business Technology Platform, and more!

[SAP HANA](https://blog.sap-press.com/tag/sap-hana)

[![Share on facebook](https://7528309.fs1.hubspotusercontent-na1.net/hub/7528309/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/facebook-color.png?width=24&name=facebook-color.png)](https://www.facebook.com/share.php?u=https%3A%2F%2Fblog.sap-press.com%2Flearn-sap-hana-commonly-used-sql-statements%3Futm_medium%3Dsocial%26utm_source%3Dfacebook) [![Share on linkedin](https://7528302.fs1.hubspotusercontent-na1.net/hub/7528302/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/linkedin-color.png?width=24&name=linkedin-color.png)](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fblog.sap-press.com%2Flearn-sap-hana-commonly-used-sql-statements%3Futm_medium%3Dsocial%26utm_source%3Dlinkedin) [![Share on twitter](https://7528304.fs1.hubspotusercontent-na1.net/hub/7528304/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/twitter-color.png?width=24&name=twitter-color.png)](https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Fblog.sap-press.com%2Flearn-sap-hana-commonly-used-sql-statements%3Futm_medium%3Dsocial%26utm_source%3Dtwitter&url=https%3A%2F%2Fblog.sap-press.com%2Flearn-sap-hana-commonly-used-sql-statements%3Futm_medium%3Dsocial%26utm_source%3Dtwitter&source=tweetbutton&text=) [![Share on email](https://7528311.fs1.hubspotusercontent-na1.net/hub/7528311/hubfs/raw_assets/public/mV0_d-web-default-modules_hubspot/img/email-color.png?width=24&name=email-color.png)](mailto:?subject=Check+out+https%3A%2F%2Fblog.sap-press.com%2Flearn-sap-hana-commonly-used-sql-statements%3Futm_medium%3Dsocial%26utm_source%3Demail&body=Check+out+https%3A%2F%2Fblog.sap-press.com%2Flearn-sap-hana-commonly-used-sql-statements%3Futm_medium%3Dsocial%26utm_source%3Demail)

### Comments

### Latest Blog Posts

[![What Is Modeling for SAP HANA?](https://blog.sap-press.com/hs-fs/hubfs/What%20is%20Modeling%20for%20SAP%20HANA.png?height=600&name=What%20is%20Modeling%20for%20SAP%20HANA.png)](https://blog.sap-press.com/what-is-modeling-for-sap-hana)

[Programming](https://blog.sap-press.com/tag/programming)

## [What Is Modeling for SAP HANA?](https://blog.sap-press.com/what-is-modeling-for-sap-hana)

[Read More](https://blog.sap-press.com/what-is-modeling-for-sap-hana)

[![An Introduction to SQLScript for SAP HANA](https://blog.sap-press.com/hs-fs/hubfs/An%20Introduction%20to%20SQLScript%20for%20SAP%20HANA.png?height=600&name=An%20Introduction%20to%20SQLScript%20for%20SAP%20HANA.png)](https://blog.sap-press.com/an-introduction-to-sqlscript-for-sap-hana)

[Programming](https://blog.sap-press.com/tag/programming)

## [An Introduction to SQLScript for SAP HANA](https://blog.sap-press.com/an-introduction-to-sqlscript-for-sap-hana)

[Read More](https://blog.sap-press.com/an-introduction-to-sqlscript-for-sap-hana)

**Subscribe to our blog!**Get notified about future blog updates.

- <https://www.facebook.com/sappress>
- <https://twitter.com/sappress>
- <https://linkedin.com/company/sap-press>
- <https://www.instagram.com/sap_press/>
- <https://blog.sap-press.com/rss.xml>

### The official SAP PRESS Blog

As the world’s leading SAP publisher, SAP PRESS’ goal is to create resources that will help you accelerate your SAP journey. The SAP PRESS Blog is designed to provide helpful, actionable information on a variety of SAP topics, from SAP ERP to SAP S/4HANA. Explore ABAP, FICO, SAP HANA, and more!

### SAP Blog Topics

- [All Topics](https://blog.sap-press.com)
- [Logistics](https://blog.sap-press.com/tag/logistics)
- [Programming](https://blog.sap-press.com/tag/programming)
- [FICO](https://blog.sap-press.com/tag/fico)
- [Administration](https://blog.sap-press.com/tag/administration)
- [Business Intelligence](https://blog.sap-press.com/tag/business-intelligence)
- [Featured](https://blog.sap-press.com/tag/featured)
- [What Is?](https://blog.sap-press.com/tag/what-is)
- [CRM & Sales](https://blog.sap-press.com/tag/crm-sales)
- [Video](https://blog.sap-press.com/tag/video)
- [Human Resources](https://blog.sap-press.com/tag/human-resources)

### Blog curated by

[![Rheinwerk Publishing & SAP PRESS Logo](https://blog.sap-press.com/hubfs/rheinwerk-sappress-logo-header-1.svg)](https://sap-press.com) [Visit the SAP PRESS Store](https://sap-press.com)

### About

- [Home](https://sap-press.com/)
- [About Us](https://sap-press.com/the-publisher/)
- [Contact](mailto:info@rheinwerk-publishing.com)
- [Legal Notes](https://sap-press.com/legal-notes/)
- [Privacy Policy](https://sap-press.com/privacy/)
- [Terms of Use](https://sap-press.com/terms/)
- [Guest Posting](https://blog.sap-press.com/guest-posting)

© 2026 Rheinwerk Publishing, Inc. | Change Privacy Options

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "SAP PRESS",
    "url" : "https://blog.sap-press.com/author/sap-press"
  },
  "dateModified" : "2026-02-26T16:10:18.206Z",
  "datePublished" : "2020-06-15T13:00:00.000Z",
  "headline" : "Learn SAP HANA: Commonly Used SQL Statements",
  "image" : [ "https://blog.sap-press.com/hubfs/Learn%20SAP%20HANA%20Commonly-Used%20SQL%20Statements.png" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog.sap-press.com/learn-sap-hana-commonly-used-sql-statements",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog.sap-press.com/hubfs/Logo-1.jpg"
    },
    "name" : "Rheinwerk Publishing, Inc."
  }
}
```