postgresql-9.2 – 我的数据库在哪里发布了postgres?

postgres拒绝工作.我正在使用9.2和一个新手.

我创建了一个数据库.我列出了它不在那里?没有错误!它去了哪里?有没有创造过?

postgres-# creatdb test
postgres-# \list
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_PH.UTF-8 | en_PH.UTF-8 | 
 template0 | postgres | UTF8     | en_PH.UTF-8 | en_PH.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_PH.UTF-8 | en_PH.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)

postgres-# 



postgres@ubuntu:/home/ubuntu$psql -h 127.0.0.1 -U postgres -d test
Password for user postgres: 
psql: FATAL:  database "test" does not exist
你有两个错误

> createdb是一个操作系统命令,它不是sql命令.在psql中,您需要使用sql语句,即:CREATE DATABASE.有关详细信息,请参见手册:http://www.postgresql.org/docs/current/static/sql-createdatabase.html
>每个sql语句都需要以;终止.由于您没有这样做,您的声明未执行,因此您没有收到错误.有关详细信息,请参见手册:http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html

postgres=# createdb test;
ERROR:  Syntax error at or near "createdb"
LINE 1: createdb test;
        ^
postgres=# create database test;
CREATE DATABASE
postgres=# \list
                                          List of databases
   Name    |  Owner   | Encoding |       Collate       |        Ctype        |   Access privileges
-----------+----------+----------+---------------------+---------------------+-----------------------
 postgres  | postgres | UTF8     | German_Germany.1252 | German_Germany.1252 | 
 template0 | postgres | UTF8     | German_Germany.1252 | German_Germany.1252 | =c/postgres          +
           |          |          |                     |                     | postgres=CTc/postgres
 template1 | postgres | UTF8     | German_Germany.1252 | German_Germany.1252 | postgres=CTc/postgres+
           |          |          |                     |                     | =c/postgres
 test      | postgres | UTF8     | German_Germany.1252 | German_Germany.1252 |
 10 rows)


postgres=#

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...