postgresql

Postgres: regex and nested queries something like Unix pipes

Command should do: Give 1 as output if the pattern "*@he.com" is on the row excluding the headings: user_id | username | email | passhash_md5 | logged_in | has_been_sent_a_moderator_message | was_last_checked_by_moderator_at_time | a_moderator ---------+----------+-----------+----------------------------------...

Best database engine for huge datasets

I do datamining and my work involves loading and unloading +1GB database dump files into MySQL. I am wondering is there any other free database engine that works better than MySQL on huge databases? is PostgreSQL better in terms of performance? I only use basic SQL commands so speed is the only factor for me to choose a database ...

php with postgresql database

i wanna to connect to postgresql database using php but it display a blank screen when submit and doesnt execute the query Thanks in advance Update: this is my code function execute_query($dbName,$query){ $host = "localhost"; $user = "postgres"; $pass = ""; $db = "test"; echo "before create connection"; $con = pg_co...

Sql recursion without recursion

I have four tables create table entities{ integer id; string name; } create table users{ integer id;//fk to entities string email; } create table groups{ integer id;//fk to entities } create table group_members{ integer group_id; //fk to group integer entity_id;//fk to entity } I want to make a query that returns all groups where a...

PostgreSQL's rules and nextval()/serial problem (very PostgreSQL-specific)

When I use a rewrite rule that splits an insert into one table into inserts to two other tables where one of the inserted values has as default nextval('some_sequence') with the same sequence for both tables, then the inserted default values are different in the two tables. This is probably due to simple text replacement by the rewrite r...

Understanding parameters in Postgres Like command in PHP

How can you use parameters in Postgres Like command? I am reading this document. I am trying to search a word lorem in the table questions and in its column body. I run unsuccessfully the following code inside PHP $result = pg_query_params ( $dbconn, "SELECT question_id, body FROM questions WHERE body ilike '%$1%'", a...

PostgreSQL and SQL Server 2008 (DBI-Link)

At work we are having a bit of trouble with spatial support of SQL Server 2008. In SQL Server 2008 we have a big system in production going on, managing a bunch of important stuff. In some of the tables, I have pairs of coordinates and need to display them to ArcGIS and other GIS software. My question here really is: Is it possible to ...

SQL filtering by multiple items in the same column

I've got two tables in SQL, one with a project and one with categories that projects belong to, i.e. the JOIN would look roughly like: Project | Category --------+--------- Foo | Apple Foo | Banana Foo | Carrot Bar | Apple Bar | Carrot Qux | Apple Qux | Banana (Strings replaced with IDs from a higher normal...

Postgresql constraint changes

I added a constraint to a Postgres table, but when I do "\d tablename" the constraint doesn't show up. How do I see what the constraints are? I'm sure this is a very basic thing, but I can't find the answer! EDIT: the constraint does actually exist and work. EDIT: first response now shows how constraint can be found using information_...

delay or waitfor statement

I have a 500,000 line sql script. update users set region_id = 9814746 where id = 101 and region_id is null; update users set region_id = 9814731 where id = 102 and region_id is null; update users set region_id = 3470676 where id = 103 and region_id is null; ... .... I want to insert a delay of 10 seconds every 50 lines. Does pgsql hav...

What do you guys think of Postgres and Firebird Databases?

I am trying to choose between postgre and firebird databasses. The database will be installed on a windows 2003 server with asp.net 3.5. i don't want to use sql server because of price issues and I don't want MySQL I had a bad experience with it and the .net connector and the membership provider. ...

Postgresql / php

I want to get id of current inserted row after executing insertion query. p.s.: I'm using postgresql database. ...

PostgreSQL: SELECT INTO - how to create indexes?

Hi, since SELECT INTO NEW_TABLE FROM QUERY creates NEW_TABLE the new table will not have any indices. Is there some way to utilise SELECT INTO with an existing table where I've created the desired indices? I am aware of INSERT INTO TABLE SELECT ... but I've encountered very bad performance compared to SELECT INTO. Thanks ...

PostgreSQL identity in JPA single table hierarchy

I'm seeing strange behaviour when using PostgreSQL in a Hibernate/JPA environment with a single table inheritance hierarchy. Firstly my environment: PostgreSQL 8.3 Spring 2.5.6SEC01 Hibernate-entitymanager 3.4.0.GA (installed from Glassfish update tool) Hibernate-distribution 3.3.1.GA (installed from Glassfish update tool) Glassfish V...

Postgresql does not prompt for password

I have a postgresql 8.3 db set up on linux box, together with a user postgres The pg_hba.conf reads local all postgres ident sameuser local all all md5 so no trusted connections from local machine. Yet when connecting via commandline with psql, no password is...

How to create a backup of a postgres database to a sql file using a PHP script?

I have the following situation. I have a PHP script that imports a CSV file and then updates the postgres database Now I need to create a backup of the database before the importing occurs The PHP files are running on one server and the postgres database on another server I tried exec(pg_dump db_name -CdiOv > /tmp/db_name_backup.sql)...

Querying multiple tables and only returning a single array?

Hey all, I am wondering what the best way to do the following is: Query up to 5 tables (depends on user input) pull back the results and return a single array. Lets say I query table A and have the results stored as a result handle (return from the pg_query() fn), shall I go ahead and convert those to an array, and then continue append...

How do I delete a stored procedure in postgresql?

How do I delete a stored procedure in postgresql? ...

How do I write a postgres stored procedure that doesn't return anything?

How do I write a simple stored procedure in postgres that doesn't return a value at all? Even with a void return type when I call the stored procedure I get a single row back. CREATE FUNCTION somefunc(in_id bigint) RETURNS void AS $$ BEGIN DELETE from test_table where id = in_id; END; $$ LANGUAGE plpgsql; ...

settings.py DATABASE_USER best practices for Django. Multiple domains/projects.

What are conventions that you recommend when I should use a new DATABASE_USER in settings.py? Should I use a new postgresql DATABASE_USER for each project database or each site on the same server? In the case of multiple projects on the same site(domain) should I use a unique DATABASE_USER per each project database? In the case of mu...