zoukankan      html  css  js  c++  java
  • postgresql小计

    1.

    postgresql执行结束后,判断结果是否成功,有几种结果

    typedef enum
    {
        PGRES_EMPTY_QUERY = 0,        /* empty query string was executed */
        PGRES_COMMAND_OK,            /* a query command that doesn't return
                                     * anything was executed properly by the
                                     * backend */
        PGRES_TUPLES_OK,            /* a query command that returns tuples was
                                     * executed properly by the backend, PGresult
                                     * contains the result tuples */
        PGRES_COPY_OUT,                /* Copy Out data transfer in progress */
        PGRES_COPY_IN,                /* Copy In data transfer in progress */
        PGRES_BAD_RESPONSE,            /* an unexpected response was recv'd from the
                                     * backend */
        PGRES_NONFATAL_ERROR,        /* notice or warning message */
        PGRES_FATAL_ERROR,            /* query failed */
        PGRES_COPY_BOTH,            /* Copy In/Out data transfer in progress */
        PGRES_SINGLE_TUPLE            /* single tuple from larger resultset */
    } ExecStatusType;

    成功并不只有一个,第一个是查询空的正确返回,第二个是没有返回值的正确返回(比如insert,update),第三个是查询有返回值的正确返回(比如select)

    2.

    用c++访问postgresql的时候,需要使用官方的libpq库,目前调查下来,这个libpq库是postgresql数据库编译出来时配对的。也就是不能像mysql一样,数据库是64位安装,可以自己编译32的connector访问。所以市面上的postgresql的connector都是在原生的libpq的基础上封装的。也就导致一个问题,就是安装什么样的postgresql,就会配戴什么样的connector。最大的影响就是数据库是32位还是64位,如果是64位,那么自己的程序也必须是64位,因为不可能在不同平台下相互访问lib库。并且从官方的release来看,postgresql从11.4开始就没有32位的发布了。所以,如果想用postgresql的话,最好尽早着手把自己的程序替换成64位

    3.

    查看postgresql的配置

    SELECT * from pg_show_all_settings()

    4.

    mysql中有一个默认配置,就是空闲连接超时后自动kill掉,默认好像是8小时
    postgresql中也有这个属性,默认是不主动kill,也就是关闭的,如果你需要可以打开,不过对于后端开发,这样更方便,避免了自己写keepalive的逻辑了

    idle_in_transaction_session_timeout (integer)

    Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds. This allows any locks held by that session to be released and the connection slot to be reused; it also allows tuples visible only to this transaction to be vacuumed. See Section 24.1 for more details about this.

    The default value of 0 disables this feature.

    5.

    如果navicat连接远程的postgresql的时候报这个错误

    no pg_hba.conf entry for host ssl off

    那是因为postgresql默认是不允许外部连接的

    所以需要修改安装目录下的pg_hba.conf文件



    # IPv4 local connections:
    host    all             all             127.0.0.1/32            md5

    修改成

    host    all             all             0.0.0.0/0            md5

    这个文档上面有介绍,0.0.0.0/0表示允许所有ip

    然后在开始菜单postgresql安装的目录下找到sql shell

    运行

    select pg_reload_conf();

    重新加载配置,注意一定要加分号

    6.

    用navicat数据传输postgresql数据库的数据的时候,如果报下面的错误

    column p.proisagg does not exist atabase d on d.datname = current_database() perhaps you meant to reference the column

    表示你的工具太老了,我用的postgresql是11.4,navicat是12.0.18,需要下载最新的navicat 12.1.x

    navicate破解

    破解的github地址

    https://github.com/Deltafox79/Navicat_Keygen

    • 下载编译
    • 安装最新的navicat
    • 把编译出来的exe拷贝到navicat的目录,不拷贝也可以,就是到时候需要自己选择一下目录
    • 运行破解软件
    • 默认选项基本上不用改,对应好自己的版本,唯一有一点注意,我们下载的应该都是中文版的,languages选择中文
    • 点击patch
    • 提示navicat.exe-x64->cracked,表示成功
    • 然后打开navicat
    • 点击注册
    • 点击破解软件serial keygen一行的generate生成注册码,然后把生成的注册码拷贝到navicat
    • 点击激活,然后选择手动激活
    • 然后把navicat的请求码拷贝到破解软件的required code中
    • 点击activation code下面的generate
    • 把activation code中的内容复制到navicat的激活码中
    • 点击激活

    可以参考

    https://www.52pojie.cn/thread-867986-1-1.html

  • 相关阅读:
    vue
    mongodb
    ejs模板引擎
    ajax
    node.js2
    node.js1
    bootstrap,ECMA
    商城
    面试:----Struts和springmvc的区别--区别上
    OpenStack
  • 原文地址:https://www.cnblogs.com/studywithallofyou/p/11351346.html
Copyright © 2011-2022 走看看