I'm using PostgreSQL 9.2
.
Is there any way to get an output like,
Database : mydb, User : myUser
using a select query?
By using the inbuilt System Information Functions
1.) Currently using database
select current_database()
2.) Connected User
select user
To get the desired output use either this
select 'Database : ' ||current_database()||', '||'User : '|| user db_details
or
select format('Database: %s, User: %s',current_database(),user) db_details
Check this part of the manual for more functions.
SELECT current_user,
user,
session_user,
current_database(),
current_catalog,
version();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.