هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

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
On this page

Show all

Universal File Access Functions

Updated on 2022-06-11 GMT+08:00

Universal file access functions provide local access interfaces for files on a database server. Only files in the database cluster directory and the log_directory directory can be accessed. Use a relative path for files in the cluster directory, and a path matching the log_directory configuration setting for log files. Only database system administrators can use these functions.

  • pg_ls_dir(dirname text)

    Description: Lists files in a directory.

    Return type: setof text

    Note: pg_ls_dir returns all the names in the specified directory, except the special entries "." and "..".

    For example:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    SELECT pg_ls_dir('./');
          pg_ls_dir       
    ----------------------
     .postgresql.conf.swp
     postgresql.conf
     pg_tblspc
     PG_VERSION
     pg_ident.conf
     core
     server.crt
     pg_serial
     pg_twophase
     postgresql.conf.lock
     pg_stat_tmp
     pg_notify
     pg_subtrans
     pg_ctl.lock
     pg_xlog
     pg_clog
     base
     pg_snapshots
     postmaster.opts
     postmaster.pid
     server.key.rand
     server.key.cipher
     pg_multixact
     pg_errorinfo
     server.key
     pg_hba.conf
     pg_replslot
     .pg_hba.conf.swp
     cacert.pem
     pg_hba.conf.lock
     global
     gaussdb.state
    (32 rows)
    
  • pg_read_file(filename text, offset bigint, length bigint)

    Description: Returns the content of a text file.

    Return type: text

    Note: pg_read_file returns part of a text file. It can return a maximum of length bytes from offset. The actual size of fetched data is less than length if the end of the file is reached first. If offset is negative, it is the length rolled back from the file end. If offset and length are omitted, the entire file is returned.

    For example:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    SELECT pg_read_file('postmaster.pid',0,100);
                 pg_read_file              
    ---------------------------------------
     53078                                +
     /srv/BigData/hadoop/data1/coordinator+
     1500022474                           +
     253088000                                +
     /var/run/FusionInsight               +
     localhost                            +
      2
    (1 row)
    
  • pg_read_binary_file(filename text [, offset bigint, length bigint,missing_ok boolean])

    Description: Returns the content of a binary file.

    Return type: bytea

    Note: pg_read_binary_file is similar to pg_read_file, except that the result is a bytea value; accordingly, no encoding checks are performed. In combination with the convert_from function, this function can be used to read a file in a specified encoding:

    1
    SELECT convert_from(pg_read_binary_file('filename'), 'UTF8');
    
  • pg_stat_file(filename text)

    Description: Returns status information about a file.

    Return type: record

    Note: pg_stat_file returns a record containing the file size, last access timestamp, last modification timestamp, last file status change timestamp, and a boolean value indicating if it is a directory. Typical use cases are as follows:

    1
    SELECT * FROM pg_stat_file('filename');
    
    1
    SELECT (pg_stat_file('filename')).modification;
    

    Examples:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    SELECT * FROM pg_stat_file('postmaster.pid');
     
     size |         access         |      modification      |         change         
    | creation | isdir 
    ------+------------------------+------------------------+------------------------
    +----------+-------
      117 | 2017-06-05 11:06:34+08 | 2017-06-01 17:18:08+08 | 2017-06-01 17:18:08+08 
    |          | f
    (1 row)
    
    1
    2
    3
    4
    5
    SELECT (pg_stat_file('postmaster.pid')).modification;
          modification      
    ------------------------
     2017-06-01 17:18:08+08
    (1 row)
    

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