Back to Yugabyte Db

Explore Yugabyte SQL

docs/content/stable/yugabyte-cloud/cloud-quickstart/qs-explore.md

2026.1.0.0-b293.7 KB
Original Source

After creating a Sandbox cluster and connecting to the cluster using Cloud Shell, you can start exploring YugabyteDB's PostgreSQL-compatible, fully-relational Yugabyte SQL API.

When you connect to your cluster using Cloud Shell with the YSQL API, the shell window incorporates a quick start guide, with a series of pre-built queries for you to run.

{{< youtube id="01owTbmSDe8" title="Explore distributed SQL in YugabyteDB Aeon" >}}

Run the tutorial

After entering your password, do the following to start the tutorial (creating a database is optional):

Create a database

While optional, it's good practice to create separate databases for different applications.

To create a database, enter the following command:

sql
yugabyte=> CREATE DATABASE yb_demo;

Next, connect to the new database using the ysqlsh \c meta-command:

sql
yugabyte=> \c yb_demo;

Create tables and insert data

Begin the tutorial by selecting the steps in the left navigation panel, then clicking the Run button for the corresponding SQL statements. The tutorial starts with the following tasks:

  1. Create a Table.

    The tutorial database includes two tables: dept for Departments, and emp for Employees. The employees table references the departments table through a foreign key constraint. The employees table also references itself through a foreign key constraint to ensure that an employee's manager is in turn an employee themselves. The table uses these constraints to ensure integrity of data, such as uniqueness and validity of email addresses.
  2. Insert Data.

    Data is added to the tables using multi-value inserts to reduce client-server round trips.

After you create the tables and insert the data, click Let's get started with the tutorials to begin the tutorial scenarios.

Quick start scenarios

The quick start includes the following scenarios:

ScenarioDescription
Basics
SQL UpdatesUpdate the salary of all employees who are not managers and display the new results.
JoinList all employees earning more than their managers using a self-join query.
Prepared StatementsGet the salary for an employee using a prepared statement.
IndexesCreate and analyze an index on the fly.
Recursive QueriesList the manager hierarchy using a recursive query.
Built-in Functions
Window FunctionsCompare employee hiring time interval by department using an analytical window function.
Regexp MatchingList all employees matching Gmail and org email domains using regular expressions for text pattern matching.
Arithmetic Date IntervalsFind employees with overlapping evaluation periods using arithmetic date intervals.
Crosstab viewDisplay the sum of salary per job and department as a cross table.
ntile FunctionSplit e-mails into 3 groups and format them.
Advanced Features
GIN IndexQuery employee skills using a GIN index on a JSON document.
Text Search IndexCreate a GIN text search index on the description column and query for words.
Stored ProceduresTransfer a commission from one employee to another using a stored procedure.
TriggersRecord the last update time of each row automatically.
Materialized ViewsPre-compute analytics for reporting using a materialized view.

To run this tutorial from your desktop shell, refer to Explore Yugabyte SQL in the Core Quick Start.

Next step

Build an application