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

ALTER FUNCTION

Updated on 2022-07-29 GMT+08:00

Function

ALTER FUNCTION modifies the attributes of a customized function.

Precautions

Only the owner of a function or a system administrator can run this statement. If a function involves operations on temporary tables, the ALTER FUNCTION cannot be used.

Syntax

  • Modify the additional parameter of the customized function.
    1
    2
    ALTER FUNCTION function_name ( [ { [ argmode ] [ argname ] argtype} [, ...] ] )
        action [ ... ] [ RESTRICT ];
    

    The syntax of the action clause is as follows:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    {CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT}
     | {IMMUTABLE | STABLE | VOLATILE}
     | {SHIPPABLE | NOT SHIPPABLE}
     | {NOT FENCED | FENCED}
     | [ NOT ] LEAKPROOF
     | { [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER }
     | AUTHID { DEFINER | CURRENT_USER }
     | COST execution_cost
     | ROWS result_rows
     | SET configuration_parameter { { TO | = } { value | DEFAULT }| FROM CURRENT}
     | RESET {configuration_parameter | ALL}
    
  • Modify the name of the customized function.
    1
    2
    ALTER FUNCTION funname ( [ { [ argmode ] [ argname ] argtype} [, ...] ] )
        RENAME TO new_name;
    
  • Modify the owner of the customized function.
    1
    2
    ALTER FUNCTION funname ( [ { [ argmode ] [ argname ] argtype} [, ...] ] )
        OWNER TO new_owner;
    
  • Modify the schema of the customized function.
    1
    2
    ALTER FUNCTION funname ( [ { [ argmode ] [ argname ] argtype} [, ...] ] )
        SET SCHEMA new_schema;
    

Parameter Description

  • function_name

    Specifies the function name to be modified.

    Value range: An existing function name.

  • argmode

    Specifies whether a parameter is an input or output parameter.

    Value range: IN, OUT, IN OUT

  • argname

    Indicates the parameter name.

    Value range: A string. It must comply with the naming convention.

  • argtype

    Specifies the parameter type.

    Value range: A valid type. For details, see Data Types.

  • CALLED ON NULL INPUT

    Declares that some parameters of the function can be invoked in normal mode if the parameter values are NULL. By default, the usage is the same as specifying the parameters.

  • RETURNS NULL ON NULL INPUT

    STRICT

    Indicates that the function always returns NULL whenever any of its arguments are NULL. If this parameter is specified, the function is not executed when there are null arguments; instead a null result is assumed automatically.

    The usage of RETURNS NULL ON NULL INPUT is the same as that of STRICT.

  • IMMUTABLE

    Indicates that the function always returns the same result if the parameter values are the same.

  • STABLE

    Indicates that the function cannot modify the database, and that within a single table scan it will consistently return the same result for the same parameter values, but that its result varies by SQL statements.

  • VOLATILE

    Indicates that the function value can change in one table scanning and no optimization is performed.

  • SHIPPABLE
  • NOT SHIPPABLE

    Indicates whether the function can be pushed down to DNs for execution.

    Functions of the IMMUTABLE type can always be pushed down to the DNs.

    Functions of the STABLE or VOLATILE type can be pushed down to DNs only if their attribute is SHIPPABLE.

  • LEAKPROOF

    Indicates that the function has no side effect and specifies that the parameter includes only the returned value. LEAKROOF can be set only by a system administrator.

  • EXTERNAL

    (Optional) The objective is to be compatible with SQL. This feature applies to all functions, including external functions.

  • SECURITY INVOKER

    AUTHID CURREN_USER

    Declares that the function will be executed according to the permission of the user that invokes it. By default, the usage is the same as specifying the parameters.

    SECURITY INVOKER and AUTHID CURREN_USER have the same functions.

  • SECURITY DEFINER

    AUTHID DEFINER

    Specifies that the function is to be executed with the permissions of the user that created it.

    The usage of AUTHID DEFINER is the same as that of SECURITY DEFINER.

  • COST execution_cost

    A positive number giving the estimated execution cost for the function.

    The unit of execution_cost is cpu_operator_cost.

    Value range: A positive number.

  • ROWS result_rows

    Estimates the number of rows returned by the function. This is only allowed when the function is declared to return a set.

    Value range: A positive number. The default is 1000 rows.

  • configuration_parameter
    • value

      Sets a specified database session parameter to a specified value. If the value is DEFAULT or RESET, the default setting is used in the new session. OFF closes the setting.

      Value range: a string

      • DEFAULT
      • OFF
      • RESET

      Specifies the default value.

    • from current

      Uses the value of configuration_parameter of the current session.

  • new_name

    Specifies the new name of a function. To change a function's schema, you must also have the CREATE permission on the new schema.

    Value range: A string. It must comply with the naming convention.

  • new_owner

    Specifies the new owner of a function. To alter the owner, the new owner must also be a direct or indirect member of the new owning role, and that role must have CREATE permission on the function's schema.

    Value range: Existing user roles.

  • new_schema

    Specifies the new schema of a function.

    Value range: Existing schemas.

Examples

Alter the execution rule of the func_add_sql function to IMMUTABLE (that is, the same result is returned if the parameter remains unchanged):

1
ALTER FUNCTION func_add_sql(INTEGER, INTEGER) IMMUTABLE;

Change the name of the func_add_sql function to add_two_number.

1
ALTER FUNCTION func_add_sql(INTEGER, INTEGER) RENAME TO add_two_number;

Change the owner of the func_add_sql function to dbadmin.

1
ALTER FUNCTION add_two_number(INTEGER, INTEGER) OWNER TO dbadmin;

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