postgresql 简单使用

编译安装的

启动数据库:/usr/local/postgresql/bin/pg_ctl -D /data/postgresql -l logfile start

停止数据库:/usr/local/postgresql/bin/pg_ctl -D /data/postgresql stop -m fast

登录数据库:/usr/local/postgresql/bin/psql postgres

 

配置文件:/data/postgresql/postgresql.conf

 

 

导出数据库:copy 数据库名 to '/home/postgres/自定名' with (delimiter '|');

 

导入数据库:copy 数据库名 from '/home/postgres/自定名' with (delimiter '|');

 
查看数据库: \l

 

切换数据库:\c 要切换的数据库名

 

创建数据库:CREATE DATABASE 数据库名;

 

创建表:CREATE table aa(id int,name char(30));

  

查看数据库中的表:\d

 

 

快速清空表:truncate table 表名; 

 

查看数据库oid:select datname,oid from pg_database where datname='postgres';

 

查看表的oid:select relname,oid from 表名 where relname='codestat';

 

开启pageinspect功能:

  找到解压的安装包目录下的”~/contrib/pageinspect

  cd ~/contrib/pageinspect

  

   编译:make

  安装:make install

  

 

  修改权限:

    cd /usr/local/postgresql/lib/

    

     chown -R postgres:postgres pageinspect.so

    cd /usr/local/postgresql/share/extension
    chown -R postgres:postgres pageinspect--*

     

   登录数据库,开启pageinspect:CREATE EXTENSION pageinspect;

  

 

posted @ 2023-07-14 10:35  leihongnu  阅读(41)  评论(0编辑  收藏  举报