`
sillycat
  • 浏览: 2551024 次
  • 性别: 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 introduction and concepts

    《PostgreSQL介绍与概念》由Bruce Momjian撰写,是一本深入探讨PostgreSQL数据库管理系统的核心原理、功能特性和管理技巧的专业书籍。此书不仅适合初学者了解PostgreSQL的基础知识,也适用于经验丰富的数据库管理员...

    Addison Wesley - PostgreSQL - Introduction and Concepts

    1. **历史背景**:介绍了PostgreSQL的起源和发展历程,从其最初的开发背景到成为当前广受欢迎的数据库系统的过程。 2. **基础知识**:为初学者提供了PostgreSQL的基本概念和技术要点,帮助读者快速入门。 3. **核心...

    Addison.PostgreSQL.Introduction.and.Concepts

    Addison.PostgreSQL.Introduction.and.Concepts

    PostgreSQL ppt2018

    PPT PG PostgreSQL 生态圈 GP PostgreSQL pg2018中国大会PPT合集

    PostgreSQL.for.Data.Architects.1783288604

    The book covers PostgreSQL from a data architect's perspective – covering topics from installation from source to designing tables using SQL Power Architect, as well as deciding replication and ...

    postgresql-42.3.1-API文档-中文版.zip

    赠送jar包:postgresql-42.3.1.jar; 赠送原API文档:postgresql-42.3.1-javadoc.jar; 赠送源代码:postgresql-42.3.1-sources.jar; 赠送Maven依赖信息文件:postgresql-42.3.1.pom; 包含翻译后的API文档:...

    PostgreSQL: Up and Running, 3rd Edition

    Chapter 1 The Basics Chapter 2 Database Administration Chapter 3 PSQL Chapter 4 PgAdmin III – Graphical GUI Chapter 5 Data Types and other objects Chapter 6 Tables, Constraints, and Indexes Chapter 7...

    PostgreSQL:简介和概念(Bruce Momjian)PostgreSQL: Introduction and Concepts (Bruce Momjian)

    PostgreSQL是一款功能强大的开源对象关系数据库管理系统(ORDBMS),它源自1986年加利福尼亚大学伯克利分校的POSTGRES项目。PostgreSQL继承了POSTGRES的核心技术,并在九十年代中期得到了快速发展和广泛应用。Bruce ...

    Postgresql 9.5.2-1

    **PostgreSQL 9.5.2-1** 是一个重要的关系型数据库管理系统版本,它在PostgreSQL系列中占据着显著的地位。此版本是专为Windows操作系统设计的,提供了丰富的功能和增强的性能,使得数据库管理和开发更为高效。 ...

    PostgreSQL1

    【PostgreSQL1】是关于PostgreSQL数据库系统的详细讨论。PostgreSQL,通常简称为Postgres,是一种功能强大的开源对象关系数据库管理系统(ORDBMS),它在数据管理、事务处理和复杂查询方面表现出色。这个标签表明...

    PostgreSQL(postgresql-13.5-1-windows-x64.exe)

    PostgreSQL(postgresql-13.5-1-windows-x64.exe)适用于Windows x86-64 PostgreSQL是一种特性非常齐全的自由软件的对象-关系型数据库管理系统(ORDBMS),是以加州大学计算机系开发的POSTGRES,4.2版本为基础的...

Global site tag (gtag.js) - Google Analytics