zoukankan      html  css  js  c++  java
  • postgresql认证和常见命令

    sudo su - postgres

    -bash-4.2$ pwd
    /var/lib/pgsql

    查看并创建新的数据库mytestdb

    -bash-4.2$ psql -l
                                      List of databases
       Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
    -----------+----------+----------+-------------+-------------+-----------------------
     postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
     template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
    (3 rows)
    -bash-4.2$ createdb mytestdb
    -bash-4.2$ psql -l
                                      List of databases
       Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
    -----------+----------+----------+-------------+-------------+-----------------------
     mytestdb  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
     template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
    (4 rows)

    进入mytestdb

    -bash-4.2$ psql mytestdb
    psql (12.4)
    Type "help" for help.
    
    mytestdb=# 

    查看help

    mytestdb=# help
    You are using psql, the command-line interface to PostgreSQL.
    Type:  copyright for distribution terms
           h for help with SQL commands
           ? for help with psql commands
           g or terminate with semicolon to execute query
           q to quit
    mytestdb=# 

    查看有哪些数据库

    mytestdb=# l
                                      List of databases
       Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
    -----------+----------+----------+-------------+-------------+-----------------------
     mytestdb  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
     template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
    (4 rows)

    查看时间

    mytestdb=# select now();
                  now              
    -------------------------------
     2020-09-06 21:37:06.656552+08
    (1 row)
    
    mytestdb=# 

    查看版本

    mytestdb=# select version();
                                                     version                                                 
    ---------------------------------------------------------------------------------------------------------
     PostgreSQL 12.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit
    (1 row)
    
    mytestdb=# 
  • 相关阅读:
    Android OpenGL ES 相机预览适配不同分辨率的手机
    Android NDK 之CPU架构兼容与包体积控制方案
    [QUANTAXIS量化分析]三因素模型(ZZ)
    [QUANTAXIS量化分析]成长股内在价值投资策略(ZZ)
    [QUANTAXIS量化分析]成长股内在价值投资策略(ZZ)
    [QUANTAXIS量化分析]羊驼策略1(zz)
    联想数据守护者在Win10上不能安装的问题
    7月14号左右转为做多 目前需要一个月左右的时间去消化 大概点位在2万以下做多 不要操作 越操作越乱
    vim :.,$d 从当前行到结尾删除
    calico
  • 原文地址:https://www.cnblogs.com/faberbeta/p/13623865.html
Copyright © 2011-2022 走看看