Database: postgres (PostgreSQL( 10.12 (Ubuntu 10.12-0ubuntu0.18.04.1(
user@my-machine:~$ psql -U gogs -h localhost -W
Password for user gogs:
psql (10.12 (Ubuntu 10.12-0ubuntu0.18.04.1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
gogs=> l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+---------+-----------------------
gogs | gogs | UTF8 | C.UTF-8 | C.UTF-8 |
postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
gogs=> c gogs
Password for user gogs:
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
You are now connected to database "gogs" as user "gogs".
gogs=> select * from user
gogs-> ;
user
------
gogs
(1 row)
任何人都可以解释为什么查询没有显示查询结果中的所有列,因为列出列我可以看到用户表中有很多列:
gogs=> d+ user
Table "public.user"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
----------------------+-------------------------+-----------+----------+----------------------------------+----------+--------------+-------------
id | bigint | | not null | nextval('user_id_seq'::regclass) | plain | |
lower_name | character varying(255) | | not null | | extended | |
name | character varying(255) | | not null | | extended | |
full_name | character varying(255) | | | | extended | |
email | character varying(255) | | not null | | extended | |
passwd | character varying(255) | | not null | | extended | |
login_source | bigint | | not null | 0 | plain | |
login_name | character varying(255) | | | | extended | |
type | integer | | | | plain | |
location | character varying(255) | | | | extended | |
website | character varying(255) | | | | extended | |
rands | character varying(10) | | | | extended | |
salt | character varying(10) | | | | extended | |
created_unix | bigint | | | | plain | |
updated_unix | bigint | | | | plain | |
last_repo_visibility | boolean | | | | plain | |
max_repo_creation | integer | | not null | '-1'::integer | plain | |
is_active | boolean | | | | plain | |
is_admin | boolean | | | | plain | |
allow_git_hook | boolean | | | | plain | |
allow_import_local | boolean | | | | plain | |
prohibit_login | boolean | | | | plain | |
avatar | character varying(2048) | | not null | | extended | |
avatar_email | character varying(255) | | not null | | extended | |
use_custom_avatar | boolean | | | | plain | |
num_followers | integer | | | | plain | |
num_following | integer | | not null | 0 | plain | |
num_stars | integer | | | | plain | |
num_repos | integer | | | | plain | |
description | character varying(255) | | | | extended | |
num_teams | integer | | | | plain | |
num_members | integer | | | | plain | |
Indexes:
"user_pkey" PRIMARY KEY, btree (id)
"UQE_user_lower_name" UNIQUE, btree (lower_name)
"UQE_user_name" UNIQUE, btree (name)
另外,当我尝试选择类似
gogs=> select email from user;
我收到错误
ERROR: column "email" does not exist
LINE 1: select email from user;
请注意,我也尝试跟随但没有成功
select "email" from user;
select "Email" from user;
select "EMAIL" from user;
这实在令人费解。有人可以帮忙吗?
从user
中进行选择将返回您的用户名。 为了从该名称的表中进行选择,您需要在它前面加上架构名称,在本例中它是公共的。 因此,您将需要执行:
SELECT * FROM public.user;