错误提示: psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 出现该问题的很多,以下是目前碰到的几种情况,之后碰到继续补充: 1.删除了/tmp路径中的.s.PGSQL.5432 与.
pgsql 常用的命令:1. 创建数据库create database name with owner username; 2. 创建用户create role with createdb ;create user user_name; 3. 修改密码alter user user_name with password 'new password'; 查询当前db中所有表的信息:"select * from pg_tables" —— 得到当前db中所有表的信息(这里pg_tables
http://www.postgresonline.com/journal/archives/239-The-wonders-of-Any-Element.html 定义函数 pgsql=# CREATE OR REPLACE FUNCTION diff_inc(IN anyelement, IN anyelement pgsql(# , OUT diff integer, OUT f_val anyelement, OUT l_val anyelement) pgsql-# RETURNS r
http://www.postgresql.org/docs/9.1/static/plpgsql-declarations.html 如果一个PL/pgSQL函数声明了输出参数,输出参数被赋予$n名称和可选的别名,和正常输入参数的作法一样.输出参数是一个从NULL开始的变量:它将被在函数的执行过程中被赋值.此参数的最后的值就是函数的返回值.例如,the sales-tax 例子可以这样实现: 例子: CREATE FUNCTION sales_tax(subtotal real, OUT ta
http://www.postgresql.org/docs/9.1/static/plpgsql-overview.html 39.1.2. Supported Argument and Result Data Types 用PL/pgSQL写的函数可以接受标量类型或者服务器支持的数组类型作为参数,它们可以返回前述的数据类型的结果.它们也能接受或返回通过名称指定的复杂类型(rwo type).也可以声明一个PL/pgSQL函数返回 record类型,此时返回的结果是一个row type,它的列
我的例子: 数据准备: create table custinfo(custid integer,callingcnt integer); ,),(,),(,); 函数生成: CREATE OR REPLACE FUNCTION get_callingcnt(custid int) RETURNS TABLE ( custid int ,callingcnt int ) AS $$ BEGIN RETURN QUERY SELECT t.custid ,t.callingcnt FROM cus