我正在使用一个全新的postgresql安装,使用"postgres"超级用户.通过以下方式登录:

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

没有错误,但尚未创建表.有什么 idea 吗?

推荐答案

createdb是一个命令行实用程序,可以从bash运行,而不是从psql运行.

create database [databasename];

注意:确保SQL语句的结尾总是;

Postgresql相关问答推荐

PostgreSQL解释分析实际时间不加总

无法在timscaleDb中创建Hypertable

GORM Golang SQL查询执行不区分大小写的搜索不起作用

让Docker Compose Container等待容器PostgreSQL并恢复

在 Postgres 中,部分索引比普通索引需要更多的时间和成本来执行

Postgres:一次插入多行时自定义upsert(存储过程?)?

返回行值和行计数的总和

在 jOOQ 中使用 $$ 引用字符串

在 postgresql 数据库 timestampz 中保留用户偏移量

从网址获取第一个字符串

联合所有 postgresql Select 子句保留顺序

推送到 Heroku 时出现带有 Postgres 的 Rails 迁移错误

PostgreSQL:根据排序顺序仅 Select 每个 id 的第一条记录

带有初始数据的 docker postgres 不会在提交中持久化

如何在构建时链接 docker 容器?

获取 PostgreSQL 中当前正在运行的查询的参数

是否可以在 CSV 格式的 Postgres COPY 命令中关闭报价处理?

没有函数匹配给定的名称和参数类型

ruby on rails jsonb 列默认值

PostgreSQL 9.1:如何连接数组中的行而不重复,加入另一个表