Postgresql 教程
PostgreSQL帐号
1. PostgreSQL 用户帐号和操作系统用户帐号是不同的,系统用户帐号是postgres.
sudo -u postgres -i
Use the operating system user postgres to create your database - as long as you haven't set up a database role with the necessary privileges that corresponds to your operating system user.
2. create new users.
sudo -u postgres createuser owning_user
创建数据库
1. 以postgres - operating system user 登录: sudo -u postgres -i
2. 创建数据库: createdb mydb
3. 删除数据库: dropdb mydb
访问数据库: psql控制台
from here.
一旦你创建了数据库,你就可以通过以下方式访问它:
运行PostgreSQL的交互式终端程序,它被称为psql, 它允许你交互地输入、编辑和执行SQL命令。psql mydb
使用一种已有的图形化前端工具,比如pgAdmin或者带ODBC或JDBC支持的办公套件来创建和管理数据库。这种方法在这份教程中没有介绍。
使用多种绑定发行的语言中的一种写一个自定义的应用。这些可能性在第 IV 部分中将有更深入的讨论。
退出psql控制台: \q
退出user shell: exit
SQL语言
每个表都是一个命名的行集合。一个给定表的每一行由同一组的命名列组成,而且每一列都有一个特定的数据类型。虽然列在每行里的顺序是固定的, 但一定要记住 SQL 并不对行在表中的顺序做任何保证(但你可以为了显示的目的对它们进行显式地排序)。
PostgreSQL连接数据库的两种方式
from here
1. pgAdmin和psql,pgAdmin是可视化工具,psql是命令行工具。
虽然pgAdmin操作起来会更加直观简单,但是在restore和backup db的时候,效率和性能会比较低下,如果db过于庞大,还会导致pgAdmin内存溢出。推荐使用psql来连接数据库进行备份和恢复db,同样大小的db,使用psql来restore会比pgAdmin快上数倍!
psql -h <dbserver_IP> -p<dbserver_port> -d <database_Name> -U <db user>
psql -h <dbserver_IP> -p<dbserver_port> -U <db user> #不指定数据库连接
psql -d test -U postgres #connect localhost database postgres=# \c mydb #\c <database_Name> #连接某个数据库
2. Using docker to install pgAdmin4
Remember to change your email address, passwd, and so on. If you forget to do that, you can still login on the system by:
- Email: youremail@yourdomain.com
- Password: yoursecurepassword
Docker has three default networking options:
- bridge - the default network for a container, it represents a virtual, isolated network for you containers
- host - the network on your computer; any container on this network is potentially visible to the Internet
- none - no network is assigned to a container
Postgresql 教程的更多相关文章
- [转]PostgreSQL教程:系统表详解
这篇文章主要介绍了PostgreSQL教程(十五):系统表详解,本文讲解了pg_class.pg_attribute.pg_attrdef.pg_authid.pg_auth_members.pg_c ...
- [转]PostgreSQL教程(十六):系统视图详解
这篇文章主要介绍了PostgreSQL教程(十六):系统视图详解,本文讲解了pg_tables.pg_indexes.pg_views.pg_user.pg_roles.pg_rules.pg_set ...
- PostgreSQL教程收集(中文文档/命令行工具/常用命令)
http://www.postgres.cn/docs/9.6/index.html(中文文档) https://www.postgresql.org/docs/10/static/auth-meth ...
- PostgreSQL教程
https://www.yiibai.com/postgresql/ https://blog.csdn.net/zhangzeyuaaa/article/details/77941039
- PostgreSql与sqlserver对比杂记
PostgreSql与MSSqlServer区别 增删查改没有语法一样. 排序Group Having 聚集函数使用一样 联结查询 ON 子句是最常见的连接条件的类型:它接收一个和 WHERE 子句相 ...
- CentOS 6.7 下 PostgreSQL 9.5 的安装与配置
#yum方式安装(不同的系统版本对应的版本也不同) yum install postgresql-server #安装指定版本 yum install https://download.postgre ...
- PostgreSQL - psql的使用与退出
PostgreSQL连接数据库的两种方式 PostgreSQL在安装时自带了pgAdmin和psql,pgAdmin是可视化工具,psql是命令行工具.虽然pgAdmin操作起来会更加直观简单,但是在 ...
- ubuntu-12.04下安装postgresql
2013-10-01 20:42:57| moniter参考资料:Ubuntu 12.04下PostgreSQL-9.1安装与配置详解(在线安装)一.安装postgresqlbamboo@bam ...
- google搜索技巧汇总
由于不能访问google,可访问ggso.in进行搜索. 简单整理记录一下常用的一些Google搜索技巧:或操作一般搜索时,如果输入多个词,默认是与的关系,如输入词1和词2,即搜索同时包含词1和词2的 ...
随机推荐
- #AcWing系列课程Level-2笔记——4. 浮点数二分算法
浮点数二分算法 编写浮点数二分,记住下面的思路,代码也就游刃有余了! 1.首先找到数组的中间值,mid=(left+right)>>1,区间[left, right]被划分成[left, ...
- 纪中23日c组T2 2159. 【2017.7.11普及】max 洛谷P1249 最大乘积
纪中2159. max 洛谷P1249 最大乘积 说明:这两题基本完全相同,故放在一起写题解 纪中2159. max (File IO): input:max.in output:max.out 时间 ...
- 剑指offer-面试题39-数组中出现次数超过一半的数字-快速排序
/* 题目: 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字. 例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}.由于数字2在数组中出现了5次,超过数组长度的一半,因此输 ...
- Tutorial: Publishing additional services for printing
Complexity:IntermediateData Requirement:Use your own data There may be occasions when you need to pu ...
- phpcms v9全站点击量排行代码
前台: <ul> {pc:content action="sitehits" siteid="1" num="10" order ...
- Ubuntu中FTP安装配置及基本概念(原创)
注:本文出自博主 Chloneda:个人博客 | 博客园 | Github | Gitee | 知乎 本文源链接:https://www.cnblogs.com/chloneda/p/ftp-inst ...
- c#在类里不能使用Response解决方法
response对应的类是HttpResponse, 在System.Web 命名字间里, 如果你在类中要使用 Response 的话, 需要使用System.Web.HttpConte ...
- 06-SV随机化
1.受约束的随机测试法(CRT) 随着设计变得越来越大,要产生一个完整的激励集来测试设计的功能变得越来越困难.解决的办法是采用受约束的随机测试法自动产生测试集.CRT环境比定向测试的环境复杂,不仅需要 ...
- CTS、CLS、CLR
CTS.CLS和CLR是.NET框架的3个核心部分,下面分别对它们进行介绍. 1)CTS Common Type System CTS即通用类型系统,它定义了如何在.NET Framework运行库 ...
- 搜索 rerank : learn to rank 算法
(1)LambdaMART 算法可参考如下两篇博客: http://www.cnblogs.com/wowarsenal/p/3900359.html http://www.cnblogs.com/w ...