postgresql-9.1

Moving postgresql data cluster

大兔子大兔子 提交于 2019-12-10 04:15:07
问题 Our postgres data folder was installed on a drive with very limited space. I'm now trying to move it over to a newly mounted drive (more space). I've followed several blog posts and they all say... stop service copy data cluster update postgresql-9.1 file (PGDATA=) restart service The service starts but when I go to connect, it gives me "could not connect to server: Connection refused" I tried telnet-ing to port 5432 and nothing. Here is the link to what I've been trying: http://www-01.ibm

How much cost check constraints in Postgres 9.x?

折月煮酒 提交于 2019-12-09 23:31:39
问题 I'd like to know if there are some benchmark to compare how much cost insert some check constraints on a table of 60 columns where on 20 i'd like to insert a constraints of NotEmpty and on 6 rows NotNull. My case is that i have on my table Empty values and Null values (that in my case means always "no data"). I'd like to unify that data values with just one. That's why I'm thinking to insert NotEmpty constraints on columns, because as i have read null value are not heavy (in byte size) as

DATE_FORMAT in postgresql

寵の児 提交于 2019-12-09 15:46:54
问题 I'm working in postgresql and I need to convert the date format in query itself, in mysql there is option called DATE_FORMAT and I can use a query like this: Select DATE_FORMAT(date_time, '%b %e, %Y, %T') from table_name is there any option in postgresql? Please let me know if any? 回答1: If I modify your Select DATE_FORMAT(date_time, '%b %e, %Y, %T') from table_name to Select DATE_FORMAT(now(), '%b %e, %Y, %T') it will return Aug 21, 2012, 16:51:30 . You can do the same thing in Postgresql:

Postgres - Is this the right way to create a partial index on a boolean column?

爷,独闯天下 提交于 2019-12-09 13:05:40
问题 I have the following table: CREATE TABLE recipemetadata ( --Lots of columns diet_glutenfree boolean NOT NULL, ); Most every row will be set to FALSE unless someone comes up with some crazy new gluten free diet that sweeps the country. I need to be able to very quickly query for rows where this value is true. I've created the index: CREATE INDEX IDX_RecipeMetadata_GlutenFree ON RecipeMetadata(diet_glutenfree) WHERE diet_glutenfree; It appears to work, however I can't figure out how to tell if

PLPGSQL Function to Calculate Bearing

。_饼干妹妹 提交于 2019-12-09 03:48:08
问题 Basically I can't get my head around the syntax of plpgsql and would appreciate some help with the following efforts. I have a table containing 1000's of wgs84 points. The following SQL will retrieve a set of points within a bounding box on this table: SELECT id, ST_X(wgs_geom), ST_Y(wgs_geom), ST_Z(wgs_geom) FROM points_table INNER JOIN (SELECT ST_Transform(ST_GeomFromText('POLYGON((-1.73576102027 1.5059743629, -1.73591122397 51.5061067655,-1.73548743495 51.5062838333,-1.73533186682 1

Prepared Statements Already Exists

假装没事ソ 提交于 2019-12-09 03:16:58
问题 I am trying to use the prepared statements in ruby with pg gem. This is how my statement looks like conn.prepare("insert_values", "insert into " + objectName + "(" + headerStr + ") values (" + prep_values + ")") conn.exec_prepared("insert_values", arr) I keep getting the error Prepared Statement insert_values already exists. How Do i Fix this?? Thanks 回答1: Try to run: conn.exec("DEALLOCATE name_of_prepared_statement") In your example: conn.exec("DEALLOCATE insert_values") Simple test and it

PL/pgSQL SELECT into an array

让人想犯罪 __ 提交于 2019-12-08 17:36:17
问题 Here's my function declaration and part of the body: CREATE OR REPLACE FUNCTION access_update() RETURNS void AS $$ DECLARE team_ids bigint[]; BEGIN SELECT INTO team_ids "team_id" FROM "tmp_team_list"; UPDATE "team_prsnl" SET "updt_dt_tm" = NOW(), "last_access_dt_tm" = NOW() WHERE "team_id" IN team_ids; END; $$ LANGUAGE plpgsql; I want team_ids to be an array of ints that I can then use in the UPDATE statement. This function give me errors like this: psql:functions.sql:62: ERROR: syntax error

Select specific data from given XML content using WHERE clasue

妖精的绣舞 提交于 2019-12-08 09:48:22
问题 I have following XML.. and I am trying to get specific data from that XML: <?xml version="1.0" encoding="utf-8"?> <html> <head> <title>report</title> <model> <instance> <uploaded_form_dc8u7x id="reportform"> <formhub> <uuid/> </formhub> <household_number/> <Survey_Name/> <photo/> <city/> <date/> <survey/> <start/> <end/> <meta> <instanceID/> </meta> </uploaded_form_dc8u7x> </instance> <bind constraint=" /uploaded_form_dc8u7x/household_number >= 2" nodeset="/uploaded_form_dc8u7x/household

Allow only postgres user list roles

大城市里の小女人 提交于 2019-12-08 07:33:27
问题 How to forbid non superusers to see other users in postgresql server? ex. If currently logged in user is not a superuser then the result from SELECT * from pg_roles; or \du should be only rows with his role 回答1: You can revoke access to the authentication IDs table in the system catalogs: REVOKE SELECT ON pg_catalog.pg_authid FROM public; REVOKE SELECT ON pg_catalog.pg_auth_members FROM public; Note that revoking access to pg_roles is not sufficient, as pg_roles is just a view over pg_authid

Get result from query in DO satement

大兔子大兔子 提交于 2019-12-08 05:11:39
问题 How to run SQL statement within an IF condition in plpgsql? I don't want to create or replace a function. This is what I tried: DO LANGUAGE plpgsql $$ BEGIN IF 'Khosla' = 'Khosla' THEN SELECT * FROM test_log limit 10; ELSE RAISE NOTICE 'not worked'; END IF; END; $$; ERROR: query has no destination for result data HINT: If you want to discard the results of a SELECT, use PERFORM instead. CONTEXT: PL/pgSQL function "inline_code_block" line 3 at SQL statement I also tried this but was unable to