ruiy

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

分类:

技术点:

相关文章:

  • 2022-01-07
  • 2022-01-15
  • 2021-11-16
  • 2021-11-16
  • 2021-11-26
  • 2021-11-26
  • 2018-11-03
  • 2021-10-03
猜你喜欢
  • 2021-06-09
  • 2021-11-05
  • 2021-10-12
  • 2021-09-18
  • 2021-11-21
  • 2022-12-23
  • 2021-11-29
相关资源
相似解决方案