USER 函数

当想要定义仅包含包括您的用户标识行的表的受限视图时,使用 USER 函数。有关如何创建视图的信息,请参阅 GBase 8s 数据库设计和实现指南GBase 8s SQL 指南:语法 中的 GRANT 和 CREATE VIEW 语句。

下列查询返回执行查询的用户的用户名(登录用户名),对表中的每行重复一次。

图: 查询

SELECT * FROM cust_calls
          WHERE user_id = USER; 
如果当前用户的用户名是 richc,该查询仅检索 cust_calls 表中 user_id = richc 的行。

图: 查询结果

customer_num  110
          call_dtime    1998-07-07 10:24
          user_id       richc
          call_code     L
          call_descr    Order placed one month ago (6/7) not received.
          res_dtime     1998-07-07 10:30
          res_descr     Checked with shipping (Ed Smith). Order sent yesterday-we
          were waiting for goods from ANZ. Next time will call with
          delay if necessary
          
          customer_num  119
          call_dtime    1998-07-01 15:00
          user_id       richc
          call_code     B
          call_descr    Bill does not reflect credit from previous order
          res_dtime     1998-07-02 08:21
          res_descr     Spoke with Jane Akant in Finance. She found the error and is
          sending new bill to customer