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

ACLItem Type

The aclitem data type is used to store object permission information. The internal implementation is of the int type, and the supported format is 'user1=privs/user2'.

The aclitem[] data type is an array consisting of ACL items. The supported format is {user1 = privs1/user3, user2 = privs2/user3}.

user1, user2, and user3 indicate the existing users or roles in the database, and privs indicates the permissions supported by the database. For details, see Table 2.

Example:

-- Create a user.
gaussdb=# CREATE USER user1 WITH PASSWORD '***********';
gaussdb=# CREATE USER user2 WITH PASSWORD '***********';
gaussdb=# CREATE USER omm WITH PASSWORD '***********';

-- Create a data table table_acl that contains three columns of the int, aclitem, and aclitem[] types.
gaussdb=# CREATE TABLE table_acl (id int,priv aclitem,privs aclitem[]);

-- Insert a data record whose content is (1,'user1=arw/omm','{omm=d/user2,omm=w/omm}') into the table_acl table.
gaussdb=# INSERT INTO table_acl VALUES (1,'user1=arw/omm','{omm=d/user2,omm=w/omm}');

-- Insert a data record whose content is (2,'user1=aw/omm','{omm=d/user2}') into the table_acl table.
gaussdb=# INSERT INTO table_acl VALUES (2,'user1=aw/omm','{omm=d/user2}');
gaussdb=# SELECT * FROM  table_acl;
 id |     priv      |          privs
----+---------------+-------------------------
  1 | user1=arw/omm | {omm=d/user2,omm=w/omm}
  2 | user1=aw/omm  | {omm=d/user2}
(2 rows)

-- Delete the table and user.
gaussdb=# DROP USER user1;
gaussdb=# DROP USER user2;
gaussdb=# DROP USER omm;
gaussdb=# DROP TABLE table_acl;