Postgresql没有创build与“createdb”作为超级用户的数据库,但不输出错误
我正在使用'postgres'超级用户进行新鲜的postgresql安装。 login:
sudo -u postgres psql postgres=# createdb database postgres-# \list List of databases Name | Owner | Encoding | Collation | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | template0 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres : postgres=CTc/postgres template1 | postgres | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres : postgres=CTc/postgres 没有错误,但表没有被创build。 有任何想法吗?
  createdb是一个命令行工具,你可以从bash运行而不是从psql运行。 要从psql create database ,请使用create database语句,如下所示: 
 create database [databasename]; 
 注意:一定要始终用你的SQL语句结束; 
晚会,但接受的答案并不能解释为什么没有显示错误。 由于这是Postgres新手经常遇到的问题,我想补充一点。
  TL / TR:总是用你的SQL语句结束; 
 因为createdb database没有结束;  psql认为语句没有完成,等待更多的input。 这通过从postgres=#到postgres-#的提示符来指示。 一个非常微妙的变化,我希望psql会做不同(更“突出”)。 
 通过inputmeta-command \list ,“当前”SQL语句被“中止”而不执行它。 
 如果被createdb已经以a ; 输出将是: 
  postgres => createdb foobar;
错误:在“createdb”处或附近的语法错误
第1行:createdb foobar;
         ^
 postgres的=> 
清楚地表明出了什么问题。