`
sillycat
  • 浏览: 2566521 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

PostgreSQL 2018(1)Installation and Introduction

 
阅读更多
PostgreSQL 2018(1)Installation and Introduction


First of all, I plan to install the current latest version on my MAC. PostgreSQL-10.3-1-osx64-bigsql.dmg
I download it from here https://www.postgresql.org/download/

PostgreSQL - relation database; psql - Command line tool; pgAdmin - GUI tool

Try to install from the source, https://www.postgresql.org/ftp/source/v10.3/
> ./configure --prefix=/Users/hluo/tool/postgresql-10.3
> make
> make install

Make and Install the tools under Contrib
> cd contrib/
> make
> make install

Put the software in Path
> sudo ln -s /Users/hluo/tool/postgresql-10.3 /opt/postgresql-10.3
> sudo ln -s /opt/postgresql-10.3 /opt/postgresql

Verify the installation
> postgres --version
postgres (PostgreSQL) 10.3

Init the Data Directory
> initdb -D /opt/postgresql/data/

Start and stop the database with command
> pg_ctl -D /opt/postgresql/data/ -l logfile start
waiting for server to start.... done
server started

List the database we have
> psql -l

List my system users
> ls /Users
Shared hluo lifesize

Create a user posters

Create a demo database
> createdb -Opostgres -Eutf-8 demo

Connect to the demo database
> psql -U postgres -d demo -h localhost -p 5432
psql (10.3)
Type "help" for help.
demo=>

List all database
demo=> \l
                                List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    | Access privileges
-----------+----------+----------+-------------+-------------+-------------------
demo      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
postgres  | hluo     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |

Create Table and Insert Data
> demo=> create table usertable(name VARCHAR(20), signupdate DATE);
CREATE TABLE
demo=> insert into usertable (name, signupdate ) values ('sillycat', '2018-05-03' );
INSERT 0 1
demo=> select * from usertable;
   name   | signupdate
----------+------------
sillycat | 2018-05-03
(1 row)

List all tables
> \d
           List of relations
Schema |   Name    | Type  |  Owner  
--------+-----------+-------+----------
public | usertable | table | postgres

Description of one table
> \d usertable
                      Table "public.usertable"
   Column   |         Type          | Collation | Nullable | Default
------------+-----------------------+-----------+----------+---------
name       | character varying(20) |           |          |
signupdate | date                  |           |          |

List my current connection
> \conninfo
You are connected to database "demo" as user "postgres" on host "localhost" at port "5432".

Exit from the command line
>\q

Use the UI Tool
https://www.pgadmin.org/download/pgadmin-4-macos/
Install PGAdmin on MAC
Open the app, it will open a browser page http://127.0.0.1:63869/browser/
Host = localhost, Username = postgres, password = postgres, database = postgres.

Query Tool, we can put query SQL there.

References:
http://sillycat.iteye.com/blog/2035746
http://sillycat.iteye.com/blog/2421923

https://www.postgresql.org/
https://www.jianshu.com/p/fedda9824f6a
https://blog.windrunner.me/postgres/
https://jin-yang.github.io/post/postgresql-introduce.html

http://postgresapp.com/
http://postgresapp.com/documentation/cli-tools.html
https://www.yiibai.com/postgresql/2013080439.html
分享到:
评论

相关推荐

    postgresql-9.0 官方手册English

    **章节**: 1.1 Installation & 1.2 Architectural Fundamentals **核心知识点**: - **安装**: PostgreSQL 9.0 支持多种操作系统,包括Windows、Linux、Mac OS X等,用户可以根据自己的操作系统选择相应的安装包...

    OpenStack.Trove.1484212223

    Chapter 1 An introduction to Database-as-a-Service Chapter 2 Downloading and Installing OpenStack Trove Chapter 3 Basic Trove Operations Chapter 4 OpenStack Trove Concepts and Architecture Chapter 5 ...

    Agile Web Development with Rails Final

    - Rails supports various databases, including MySQL, PostgreSQL, and SQLite. Developers configure the database connection in the `config/database.yml` file. 5. **Keeping Up-to-Date:** - Staying ...

    postgre7.4.2 manul

    - **1.1 Installation**:安装指南会详细介绍如何在不同的操作系统上安装PostgreSQL 7.4.2,包括Linux、Windows和macOS等。 - **1.2 Architectural Fundamentals**:这部分概述了PostgreSQL的架构基础,包括服务器...

    Professional_Linux_Programming.pdf

    Installation and Configuration of PHP 5 401 Apache Basic Authentication 402 Apache and SSL 402 Integrating SSL with HTTP Authentication 403 MySQL 404 Installing MySQL 404 Configuring and Starting the ...

    bugzilla用户指导

    1. **Perl**:安装Perl环境是使用Bugzilla的前提条件之一。建议使用最新稳定版的Perl。 2. **数据库引擎**: - **MySQL**:是最常用的数据库引擎之一,适用于大多数应用场景。 - **PostgreSQL**:提供更高级的...

    pinpoint 中文使用文档,供大家学习

    另外,文档作者还提供了一些中文翻译的文档链接,比如快速开始(Quick Start)、安装指南(Installation Guide)、插件示例(Plugin Samples)、告警(Alarm)等。 综上所述,Pinpoint是一个功能强大的APM工具,...

Global site tag (gtag.js) - Google Analytics