Bu sayfa henüz yerel dilinizde mevcut değildir. Daha fazla dil seçeneği eklemek için yoğun bir şekilde çalışıyoruz. Desteğiniz için teşekkür ederiz.

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

Network Address Functions and Operators

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

cidr and inet Operators

The operators <<, <<=, >>, and >>= test for subnet inclusion. They consider only the network parts of the two addresses (ignoring any host part) and determine whether one network is identical to or a subnet of the other.

  • <

    Description: Is less than

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.5' < inet '192.168.1.6' AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • <=

    Description: Is less than or equals

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.5' <= inet '192.168.1.5' AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • =

    Description: Equals

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.5' = inet '192.168.1.5' AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • >=

    Description: Is greater than or equals

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.5' >= inet '192.168.1.5' AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • >

    Description: Is greater than

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.5' > inet '192.168.1.4' AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • <>

    Description: Does not equal to

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.5' <> inet '192.168.1.4' AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • <<

    Description: Is contained in

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.5' << inet '192.168.1/24' AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • <<=

    Description: Is contained in or equals

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1/24' <<= inet '192.168.1/24' AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • >>

    Description: Contains

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1/24' >> inet '192.168.1.5' AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • >>=

    Description: Contains or equals

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1/24' >>= inet '192.168.1/24' AS RESULT;
     result 
    --------
     t
    (1 row)
    
  • ~

    Description: Bitwise NOT

    For example:

    1
    2
    3
    4
    5
    SELECT ~ inet '192.168.1.6' AS RESULT; 
        result     
    ---------------
     63.87.254.249
    (1 row)
    
  • &

    Description: The AND operation is performed on each bit of the two network addresses.

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.6' & inet '10.0.0.0' AS RESULT;
     result  
    ---------
     0.0.0.0
    (1 row)
    
  • |

    Description: The OR operation is performed on each bit of the two network addresses.

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.6' | inet '10.0.0.0' AS RESULT;
       result    
    -------------
     202.168.1.6
    (1 row)
    
  • +

    Description: Addition

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.6' + 25 AS RESULT;
        result    
    --------------
     192.168.1.31
    (1 row)
    
  • -

    Description: Subtraction

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.43' - 36 AS RESULT;
       result    
    -------------
     192.168.1.7
    (1 row)
    
  • -

    Description: Subtraction

    For example:

    1
    2
    3
    4
    5
    SELECT inet '192.168.1.43' - inet '192.168.1.19' AS RESULT;
     result 
    --------
         24
    (1 row)
    

cidr and inet Functions

The abbrev, host, and text functions are primarily intended to offer alternative display formats.

  • abbrev(inet)

    Description: Abbreviated display format as text

    Return type: text

    For example:

    1
    2
    3
    4
    5
    SELECT abbrev(inet '10.1.0.0/16') AS RESULT;
       result    
    -------------
     10.1.0.0/16
    (1 row)
    
  • abbrev(cidr)

    Description: Abbreviated display format as text

    Return type: text

    For example:

    1
    2
    3
    4
    5
    SELECT abbrev(cidr '10.1.0.0/16') AS RESULT;
     result  
    ---------
     10.1/16
    (1 row)
    
  • broadcast(inet)

    Description: Broadcast address for network

    Return type: inet

    For example:

    1
    2
    3
    4
    5
    SELECT broadcast('192.168.1.5/24') AS RESULT;
          result      
    ------------------
     192.168.1.255/24
    (1 row)
    
  • family(inet)

    Description: Extracts family of address; 4 for IPv4, 6 for IPv6

    Return type: int

    For example:

    1
    2
    3
    4
    5
    SELECT family('::1') AS RESULT;
     result 
    --------
          6
    (1 row)
    
  • host(inet)

    Description: Extracts IP address as text.

    Return type: text

    For example:

    1
    2
    3
    4
    5
    SELECT host('192.168.1.5/24') AS RESULT;
       result    
    -------------
     192.168.1.5
    (1 row)
    
  • hostmask(inet)

    Description: Constructs host mask for network.

    Return type: inet

    For example:

    1
    2
    3
    4
    5
    SELECT hostmask('192.168.23.20/30') AS RESULT;
     result  
    ---------
     0.0.0.3
    (1 row)
    
  • masklen(inet)

    Description: Extracts subnet mask length.

    Return type: int

    For example:

    1
    2
    3
    4
    5
    SELECT masklen('192.168.1.5/24') AS RESULT;
     result 
    --------
         24
    (1 row)
    
  • netmask(inet)

    Description: Constructs a subnet mask for the network.

    Return type: inet

    For example:

    1
    2
    3
    4
    5
    SELECT netmask('192.168.1.5/24') AS RESULT;
        result     
    ---------------
     255.255.255.0
    (1 row)
    
  • network(inet)

    Description: Extracts network part of address.

    Return type: cidr

    For example:

    1
    2
    3
    4
    5
    SELECT network('192.168.1.5/24') AS RESULT;
         result     
    ----------------
     192.168.1.0/24
    (1 row)
    
  • set_masklen(inet, int)

    Description: Sets subnet mask length for inet value.

    Return type: inet

    For example:

    1
    2
    3
    4
    5
    SELECT set_masklen('192.168.1.5/24', 16) AS RESULT;
         result     
    ----------------
     192.168.1.5/16
    (1 row)
    
  • set_masklen(cidr, int)

    Description: Sets subnet mask length for cidr value.

    Return type: cidr

    For example:

    1
    2
    3
    4
    5
    SELECT set_masklen('192.168.1.0/24'::cidr, 16) AS RESULT;
         result     
    ----------------
     192.168.0.0/16
    (1 row)
    
  • text(inet)

    Description: Extracts IP address and subnet mask length as text.

    Return type: text

    For example:

    1
    2
    3
    4
    5
    SELECT text(inet '192.168.1.5') AS RESULT;
         result     
    ----------------
     192.168.1.5/32
    (1 row)
    

Any cidr value can be cast to inet implicitly or explicitly; therefore, the functions shown above as operating on inet also work on cidr values. An inet value can be cast to cidr. After the conversion, any bits to the right of the subnet mask are silently zeroed to create a valid cidr value. In addition, you can cast a text string to inet or cidr using normal casting syntax. For example, inet(expression) or colname::cidr.

macaddr Functions

The function trunc(macaddr) returns a MAC address with the last 3 bytes set to zero.

trunc(macaddr)

Description: Sets last 3 bytes to zero.

Return type: macaddr

For example:

1
2
3
4
5
SELECT trunc(macaddr '12:34:56:78:90:ab') AS RESULT;
      result       
-------------------
 12:34:56:00:00:00
(1 row)

The macaddr type also supports the standard relational operators (such as > and <=) for lexicographical ordering, and the bitwise arithmetic operators (~, & and |) for NOT, AND and OR.

Sitemizi ve deneyiminizi iyileştirmek için çerezleri kullanırız. Sitemizde tarama yapmaya devam ederek çerez politikamızı kabul etmiş olursunuz. Daha fazla bilgi edinin

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback