PostgreSQL - 通过 pgAdmin UI 创建一个新的数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8200917/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 23:12:50  来源:igfitidea点击:

PostgreSQL - create a new DB through pgAdmin UI

postgresqluser-interfacepgadmin

提问by Yatendra Goel

I have installed PostgreSQL DB server on my Ubuntu machine. Now I want to create a new Database through some GUI application. I tried pgAdmin but didn't find any option to create a new DB. But I could add existing db servers.

我已经在我的 Ubuntu 机器上安装了 PostgreSQL 数据库服务器。现在我想通过一些 GUI 应用程序创建一个新的数据库。我尝试了 pgAdmin,但没有找到任何创建新数据库的选项。但我可以添加现有的数据库服务器。

Is there any way to create a DB and then tables through pgAdmin or some other app.

有什么方法可以通过 pgAdmin 或其他一些应用程序创建数据库,然后创建表。

Basically I am looking for an application for PostgreSQL like SQLYogfor MySQL.

基本上我正在寻找像SQLYogfor MySQL这样的 PostgreSQL 应用程序。

回答by Frank Heikens

  1. Open pgAdmin
  2. Connect to database server
  3. Edit => New Object => New database
  4. done
  1. 打开 pgAdmin
  2. 连接到数据库服务器
  3. 编辑 => 新对象 => 新数据库
  4. 完毕

Or use plain SQL when connection to any database: CREATE DATABASE my_database;

或者在连接到任何数据库时使用普通 SQL: CREATE DATABASE my_database;

回答by Bhupathy A P

HI ... Verify that u have done above steps to install the postgresql properly ... and follow the below instructions to create a database in POSTGRESQL

嗨...验证您是否已完成上述步骤以正确安装 postgresql ...并按照以下说明在 POSTGRESQL 中创建数据库

INSTALL POSTGRESQL

安装 PostgreSQL

1.Install latest PostgreSQL 9.1 in console:

1.在控制台安装最新的PostgreSQL 9.1:

sudo apt-get install postgresql libpq-dev

sudo apt-get install postgresql libpq-dev

2.PostgreSQL has a super user is called postgres. Change user to the PostgreSQL user:

2.PostgreSQL有一个超级用户叫postgres。将用户更改为 PostgreSQL 用户:

sudo su - postgres

3.Change password of postgres user:

3.修改postgres用户密码:

psql -d postgres -U postgres

psql (9.1.3) Type "help" for help

psql (9.1.3) 输入“help”获取帮助

    postgres=# alter user postgres with password 'YOUR_NEW_PASSWORD';
    ALTER ROLE
    postgres=# \q
    #logout postgres user
    logout

4.Restart the PostgreSQL server:

4.重启PostgreSQL服务器:

sudo /etc/init.d/postgresql restart

pgAdmin III: PostgreSQL administration and management tools

pgAdmin III:PostgreSQL 管理和管理工具

If pgAdminIII is not installed, the installation is easy:

如果没有安装 pgAdminIII,安装很简单:

sudo apt-get install pgadmin3

ADD A SEVER

添加服务器

Open pgAdminIII and add new localhost server. Go to menu File > Add Server

打开 pgAdminIII 并添加新的 localhost 服务器。转到菜单文件 > 添加服务器

Set up pgAdmin III server instrumentation:

设置 pgAdmin III 服务器检测:

When connecting to a PostgreSQL database using pgAdmin you may receive an error letting you know that the server instrumentation is not installed.

使用 pgAdmin 连接到 PostgreSQL 数据库时,您可能会收到一条错误消息,告知您未安装服务器检测。

Install postgresql-contrib package:

安装 postgresql-contrib 包:

sudo apt-get install postgresql-contrib

Install adminpack extension:

安装 adminpack 扩展:

sudo -u postgres psql
postgres=# CREATE EXTENSION "adminpack";
postgres=# \q

CREATE DATABASE

创建数据库

1.Double Click your database in Left pane on PGAdmin to select it

1.在PGAdmin的左窗格中双击您的数据库以选择它

2.Now click the a Icon named "SQL" ,probably 6th icon, and type CREATE table query in resultant window

2.现在单击名为“SQL”的图标,可能是第 6 个图标,然后在结果窗口中键入 CREATE table query

EXAMPLE:

例子:

3.Create table query

3.创建表查询

CREATE TABLE explore(
SUBJECT  TEXT     NOT NULL,
COMPANY  CHAR(50) NOT NULL,
PNAME    TEXT     NOT NULL,
PHONE    INT      NOT NULL,
EMAIL    CHAR(50) NOT NULL,
REMARKS  CHAR(200) NOT NULL
);  

Post any queries below.............Have a error free day.

在下面发布任何疑问…………祝您度过一个没有错误的日子。

回答by Boris

One of problems with DB creating is connected to permissions.

创建数据库的问题之一与权限有关。

If there are no grant for creating database, the path "Object -> Create -> Database" is off (unclickable) and you can't pick this menu option. Likewise, "Databases -> Right Mouse Button" doesn't have "Create" option. One more sign of this case is the reaction in SQL:

如果没有创建数据库的授权,路径“对象 -> 创建 -> 数据库”是关闭的(不可点击),你不能选择这个菜单选项。同样,“数据库 - > 鼠标右键”没有“创建”选项。这种情况的另一个迹象是 SQL 中的反应:

CREATE DATABASE DBNAME; 

ERROR:  permission denied to create database
********** Error **********

To solve the problem you can reconnect to the Server with the first login ('postgres' for example). And afterwards the menu will work.

要解决此问题,您可以在第一次登录时重新连接到服务器(例如“postgres”)。之后菜单将起作用。

回答by Erwin Brandstetter

Of course you can create a database with pgAdmin.

当然你可以用 pgAdmin 创建一个数据库。

You have to understand the basic concept of PostgreSQL. First you have to connect to a database cluster, which you can only do by connecting to a database in that cluster. Now, if your database does not exist, yet, there is the default maintenance db postgresyou can connect to. Connect to it and issue CREATE DATABASEthere. Then change to the new database.

您必须了解 PostgreSQL 的基本概念。首先,您必须连接到数据库集群,这只能通过连接到该集群中的数据库来完成。现在,如果您的数据库尚不存在,则postgres可以连接到默认的维护数据库。连接到它并CREATE DATABASE在那里发出。然后切换到新的数据库。

回答by Dulangi_Kanchana

On windows right click on the db connector

enter image description here

在 Windows 上右键单击 db 连接器

在此处输入图片说明

My db connector is PostgreSQL->Create->Database, expand the database
enter image description here

我的db连接器是PostgreSQL->Create->Database,展开数据库
在此处输入图片说明

Next expand schema enter image description here

下一个展开模式 在此处输入图片说明

under which tables is found, then right click, and create tables
To create tables Expand database->under that expand schema->under tables , click on create tables

To add columns and data types to tables
under the respective table, right click properties and select column fields and add name of columns, data types as needed

properties->columns

enter image description here

在哪个表下找到,然后右键单击,然后创建表
要创建表 展开数据库-> 在该展开模式下-> 在表下,单击创建表

要将列和数据类型添加到
相应表下的表,右键单击属性和选择列字段并根据需要添加列名称、数据类型

属性->列

在此处输入图片说明