In psql, if one types 'select * from user' you'll get something like the following back:
current_user
--------------
postgres
What is user in this context?
The PostgreSQL SELECT statement retrieves data from a single or several tables in a database, and returns the data in a result table, called a result-set. Use the SELECT statement to return one or more rows matching the specified criteria from the database tables.
Wildcards in PostgreSQL is used to find matching rows values from tables; it is also used to find matching patterns rows from tables, Wildcards is also used to find matching rows, column and tables names; the output of the wildcard operator will return matching name, which was table name, column name or rows, In ...
Removing duplicate rows from a query result set in PostgreSQL can be done using the SELECT statement with the DISTINCT clause. It keeps one row for each group of duplicates. The DISTINCT clause can be used for a single column or for a list of columns.
In PostgreSQL, the select into statement to select data from the database and assign it to a variable. Syntax: select select_list into variable_name from table_expression; In this syntax, one can place the variable after the into keyword.
In this context, user
is a reserved internal Postgres function that represents the current user logged in to the database.
This query can also be written as:
SELECT user;
Which should yield the same thing. Note, if you want to actually reference or create a table named user
you'll have to use quotes, or fully qualify the schema it lives in. For example:
CREATE TABLE "user"
(
id int2 not null
);
will work but:
CREATE TABLE user
(
id int2 not null
);
Will yield an error.
Here's a reference for other system information functions:
http://www.postgresql.org/docs/9.0/static/functions-info.html
See the Postgresql Documentation on system functions.
Basically "select * from user
" is one of the Postgresql-specific ways of finding the current user. It is functionally the same as using the current_user function eg: "select current_user()
".
Other special functions that can be used as tables in queries include:
current_catalog
current_schema
If You are looking for list of users i should seek in pg_user table; SELECT * FROM pg_user;
Your Query get all data from result of special function named user. That function returns username of current_user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With