www.cnblogs.com/ruiyqinrui

开源、架构、Linux C/C++/python AI BI 运维开发自动化运维。 春风桃李花 秋雨梧桐叶。“力尽不知热 但惜夏日长”。夏不惜,秋不获。@ruiY--秦瑞

python爬虫,C编程,嵌入式开发.hadoop大数据,桉树,onenebula云计算架构.linux运维及驱动开发.

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

preface,熟悉pgsql sql Language article disorder;

1,pgsql数据库控制台Cli(command line interface) help mannual;

注意\g == ; terminate with semicolon to execute query

SQL command help

psql command help

2,基于shell创建psql 数据库及owner user

createuser,createdb --superuser 加此参数,在新建user登进psql看看命令提示符是=#(超级用户命令行提示符) 还是=>普通用户提示符;

 3,显示当前用户下的表及表结构

4,切换数据库连接

mysql中是用use + dbName

[Note byRuiy tip memorize]

  • \l:列出所有数据库。
  • \c [database_name]:连接其他数据库。
  • \d:列出当前数据库的所有表格。
  • \d [table_name]:列出某一张表格的结构。
  • \du:列出所有用户。

    \[shell-based createPsqlUser]创建psql数据库及用户;

sudo -u postgres createuser --superuser dbuser

sudo -u postgres psql

\password dbuser

sudo -u postgres createdb -O dbuser exampledb

(使用psql control)

useradd ruiy;

sudo -U postgres -d postgres -h 127.0.0.1 -p 5432

create user ruiy with password '321';

create database ruiy owner ruiy;

grant all privileges on database ruiy to ruiy;

5,psql服务器监听设置及客户端连接

pg_ctl restart

posted on 2014-09-07 21:44  秦瑞It行程实录  阅读(924)  评论(0编辑  收藏  举报
www.cnblogs.com/ruiyqinrui