Updated on 2024-06-03 GMT+08:00

ALTER DIRECTORY

Description

Modifies directory attributes.

Precautions

  • Currently, only the directory owner can be changed.
  • When enable_access_server_directory is set to off, only the initial user is allowed to change the directory owner. When enable_access_server_directory is set to on, users with the SYSADMIN permission and the directory object owner can change the directory object owner, and the user who changes the owner is required to be a member of the new owner.

Syntax

1
2
ALTER DIRECTORY directory_name
    OWNER TO new_owner;

Parameters

  • directory_name

    Specifies the name of a directory to be modified. The value must be an existing directory name.

  • new_owner

    Specifies the new owner of the directory.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
-- Create a directory.
gaussdb=# CREATE OR REPLACE DIRECTORY dir as '/tmp/';

-- Create a user.
gaussdb=# CREATE USER jim PASSWORD '********';

-- Change the owner of the directory.
gaussdb=# ALTER DIRECTORY dir OWNER TO jim;

-- Delete the directory object.
gaussdb=# DROP DIRECTORY dir;

-- Delete the user.
gaussdb=# DROP USER jim;

Helpful Links

CREATE DIRECTORY and DROP DIRECTORY