加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

PostgreSQL中current_user和current_user()的区别

发布时间:2020-12-13 17:55:51 所属栏目:百科 来源:网络整理
导读:今天看到网上有人在问在 POSTGRESQL 中 Select current_user 可以执行成功,但是 select current_user() 却会失败,这是为什么呢 ? 碰巧今天看到书上有一个小节,叫预定义变量的,里面列出了 4 个。 aligputf8=# select current_date; date ------------ 201

今天看到网上有人在问在POSTGRESQLSelect current_user 可以执行成功,但是select current_user() 却会失败,这是为什么呢?

碰巧今天看到书上有一个小节,叫预定义变量的,里面列出了4 个。

aligputf8=# select current_date;

date

------------

2010-04-22

(1 row)

aligputf8=# select current_time;

timetz

--------------------

17:47:53.066679+08

aligputf8=# select current_timestamp;

now

-------------------------------

2010-04-22 17:47:59.626851+08

aligputf8=# select current_user;

current_user

--------------

etl

(1 row)

下面加上括号试试

aligputf8=# select current_user();

ERROR: syntax error at or near "(" --报错了 没有这个函数

LINE 1: select current_user();

^

aligputf8=# select now(); --这是个函数

2010-04-22 17:49:40.125055+08

(1 row)

aligputf8=# select now; --去掉括号就不行了

ERROR: column "now" does not exist

LINE 1: select now;

^

一类是函数,一类是预定义变量。个人理解哈。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读