Esta página ainda não está disponível no idioma selecionado. Estamos trabalhando para adicionar mais opções de idiomas. Agradecemos sua compreensão.

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
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

SQL Syntax

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

SQL Syntax Differences Between Data Backends and Databases

  • To transfer parameters carried in a backend request to an SQL statement, use ${parameter name} to mark the parameters. Parameters of the String type must be enclosed in single quotation marks, whereas parameters of the int type do not need to be enclosed.

    In the following example, name is a parameter of the String type and id is a parameter of the int type.

    select * from table01 where name='${name}' and id=${id}
  • Parameters can be transferred in the headers, parameters, or body of backend requests.
  • If the character string in an SQL statement contains keywords, you must escape the character string.

    For example, if a field name is delete, the SQL statement must be written in the following format:

    select `delete` from table01
  • If Precompiling is selected during data backend configuration, input parameters are used for fuzzy match query, and the match field contains %, use the CONCAT function for concatenation.

    In the following example, name is a string.

    select * from table01 where name like concat('%',${name})
NOTE:

If precompiling has been enabled and an SQL statement references backend request parameters of multiple data types, the input parameters will be converted to String by default. Therefore, when the SQL statement is executed, the corresponding function needs to be called to convert non-String parameters.

For example, if both the name (String type) and id (int type) parameters are transferred to an SQL statement, the id parameter will be converted to the String type. Therefore, you need to use a conversion function to convert the id parameter back to the int type in the SQL statement. The following uses the cast() function as an example. The conversion function varies depending on the database type in use.

select * from table01 where name='${name}' and id=cast('${id}' as int)

SQL Query Examples (Similar to UPDATE and INSERT)

  • Query with parameters specified

    Transfer parameters (Headers, Parameters, or Body) carried in backend requests to SQL statements to provide flexible conditional query or data processing capabilities for the SQL statements.

    • For APIs using the GET or DELETE method, obtain parameters from the request URL.
    • For APIs using the POST or PUT method, obtain parameters from the request body. Note: The body is in application/x-www-form-urlencoded format.
    select * from table01 where 1=1 and col01 = ${param01};
  • Query with optional parameters
    select * from table01 where 1=1 [and col01 = ${param01}] [and col02 = ${param02}]
  • IN query
    select * from table01 where 1=1 and col01 in ('${param01}','${param02}');
  • UNION query
    By default, duplicate data will be deleted. To return all data, use the keywords union all.
    select * from table01 
    union [all | distinct]
    select * from table02;
  • Nested query
    select * from table01 where 1=1 and col01 in (select col02 from table02 where col03 is not null);

Native Commands Compatible with NoSQL (such as MongoDB and Redis)

  • Command formats supported by the Redis data source:

    GET, HGET, HGETALL, LRANGE, SMEMBERS, ZRANGE, ZREVRANGE, SET, LPUSH, SADD, ZADD, HMSET, DEL

  • Command formats supported by the MongoDB data source:

    find

NoSQL Examples

  • Insert a key of the String type. The value is obtained from the request parameter.
    set hello ${parm01}
  • Query the key of the String type.
    get hello

Usamos cookies para aprimorar nosso site e sua experiência. Ao continuar a navegar em nosso site, você aceita nossa política de cookies. Saiba mais

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback