Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Formatting of SQL Queries

Updated on 2023-03-17 GMT+08:00

Data Studio supports formatting and highlighting of SQL queries and PL/SQL statements.

PL/SQL Formatting

Follow the steps to format PL/SQL statements:

  1. Select the PL/SQL statements to be formatted.
  2. Click on the toolbar to format the query.

    Alternatively, use the key combination Ctrl+Shift+F or choose Edit > Format from the main menu.

    The PL/SQL statements are formatted.

SQL Formatting

Data Studio supports formatting of simple SQL SELECT, INSERT, UPDATE, DELETE statements which are syntactically correct. The following are some of the statements for which formatting is supported:

  1. The SELECT statement must be made of the following clauses:
    • Target list
    • FROM clause (including JOIN)
    • Where
    • Group by
    • Having
    • Order by
    • Common table expression

    SELECT statement without SET operations like UNION, UNION ALL, MINUS, INTERSECT and so on

    SELECT statements without sub-queries

  2. The INSERT statement is made of the following clauses only:
    • Insert Into Table name
    • Values
    • Values Column List
    • RETURNING
  3. The UPDATE statement is made of the following clauses only:
    • Update Table name
    • SET
    • FROM clause (including JOIN)
    • Where
    • RETURNING
  4. The DELETE statement is made of the following clauses only:
    • Delete From Table name
    • USING clause (including JOIN)
    • Where
    • RETURNING

Follow the steps below to format SQL queries:

  1. Select the SQL query statements to be formatted.
  2. Click on the toolbar to format the query.

    Alternatively, use the key combination Ctrl+Shift+F or choose Edit > Format from the main menu.

    The query is formatted.

    The following table describes the query formatting rules.

    Table 1 Query formatting rules

    Statement

    Clause

    Formatting Rule

    SELECT

    SELECT list

    Line break before first column

    Indent column list

    FROM

    Line break before FROM

    Line break after FROM

    Indent FROM list

    Stack FROM list

    Line break before JOIN

    Line break after JOIN

    Line break after JOIN

    Line break before ON

    Line break after ON

    Indent table after JOIN

    Indent ON condition

    WHERE

    Line break before WHERE

    Line break after WHERE

    Place WHERE condition on single line

    Place WHERE condition on single line

    GROUP BY

    Line break before GROUP

    Line break before GROUP BY expression

    Indent column list

    Stack column list

    HAVING

    Line break before HAVING

    Line break after HAVING

    Indent HAVING condition

    ORDER BY

    Line break before ORDER

    Line break after BY

    Indent column list

    Stack column list

    CTE

    Indent subquery braces

    Each CTE in a new line

    INSERT

    INSERT INFO

    Line break before opening brace

    Line break after opening brace

    Line break before closing brace

    Indent column list brace

    Indent column list

    Line break before VALUES

    Stack column list

    Line break before VALUES

    Line break before opening brace

    Line break after opening brace

    Line break before closing brace

    Indent VALUES expressions list braces

    Indent VALUES expressions list

    Stack VALUES expressions list

    DEFAULT

    Line break before DEFAULT

    Indent DEFAULT keyword

    CTE

    Each CTE in a new line

    RETURNING

    Line break before RETURNING

    Line break after RETURNING

    Indent RETURNING column list

    Place RETURNING column List on single line

    UPDATE

    UPDATE Table

    Line break before table

    Indent table

    SET Clause

    Line break before SET

    Indent column assignments list

    Indent column assignments list

    FROM CLAUSE

    Line break before FROM

    Line break after FROM

    Indent FROM list

    Stack FROM list

    JOIN CLAUSE(FROM CLAUSE)

    Line break before JOIN

    Line break after JOIN

    Line break before ON

    Line break after ON

    Indent table after JOIN

    Indent ON condition

    WHERE CLAUSE

    Line break before WHERE

    Line break after WHERE

    Place WHERE condition on single line

    Place WHERE condition on single line

    CTE

    Each CTE in a new line

    RETURNING

    Line break before RETURNING

    Line break after RETURNING

    DELETE

    USING CLAUSE

    Indent RETURNING column list

    Line break before FROM

    Line break after FROM

    Indent USING list

    Stack FROM list

    JOIN CLAUSE

    Line break before JOIN

    Line break after JOIN

    Line break before ON

    Line break after ON

    Indent table after JOIN

    Indent ON condition List

    WHERE CLAUSE

    Line break before WHERE

    Line break after WHERE

    Place WHERE condition on single line

    Stack WHERE condition list

    CTE

    Each CTE in a new line

    RETURNING

    Line break before RETURNING

    Line break after RETURNING

    Indent RETURNING column list

Data Studio supports automatic highlighting of the following punctuation mark's pair when cursor is placed before or after the punctuation mark or the punctuation mark is selected.

  • Brackets - ( )
  • Square brackets - [ ]
  • Braces - { }
  • Single-quoted string literals - ' '
  • Double-quoted string literals - " "

Follow the steps below to change case for SQL queries and PL/SQL statements:

Method 1

  1. Select the text, and choose Edit > Upper Case/Lower Case.

    The text changes to the case selected.

Method 2:

  1. Select the text, and choose or from the toolbar.

    The text changes to the case selected.

Method 3:

  1. Select the text, and press Ctrl+Shift+U to change to the upper case or Ctrl+Shift+L to change to the lower case.

    The text changes to the case selected.

SQL Highlighting

Keywords are highlighted automatically when you enter them (according to the default color scheme) as shown below:

The following figure shows the default color scheme for the specified type of syntax:

You can also customize SQL highlighting schemes for specific types of syntax. For details, see Syntax Highlighting.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback