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=#
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。