postgresql

Porting from MS Access

I've recently been given a MS Access .mdb database file and asked to make it usable in a Linux system. What I'm looking for is a way to convert the Access database to an open-source database such as MySQL or PostGres. I don't have MS Office, and it's a one-time project for a volunteer organization so I don't want to spend money if it...

Error installing PostgreSQL on Mac OS X 10.5 using MacPorts

I've installed PostgreSQL using MacPorts on a couple of different computers, no problem, but when it comes to my own laptop, I cannot get it to build. When I do this command: sudo port install postgresql83 I get this error: checking test program... failed configure: error: Could not execute a simple test program. This may be a prob...

How do I discover the structure of a PostgreSQL database?

I need to write a PHP script that will output data from a PostgreSQL database that I do not know the structure of. What query will return the names of all tables in a database? And what query will list the names of all columns in a table? ...

PostgreSQL - tree organization

I'm working on a project wich requires a tree of categories, organized as id, parent, title table. Which are the best ways to retrieve category and its subcategories(and a full tree, if root categories have parent=0) in Postgres? I'm looking for a pure database solution, but if there is a way for Ruby and PHP - it will be great too. The...

MySQL vs PostgreSQL? Which should I choose for my Django project?

My Django project is going to be backed by a large database with several hundred thousand entries, and will need to support searching (I'll probably end up using djangosearch or a similar project.) Which database backend is best suited to my project and why? Can you recommend any good resources for further reading? ...

PostgreSQL - fetch the row which has the Max value for a column

I'm dealing with a Postgres table (called "lives") that contains records with columns for time_stamp, usr_id, transaction_id, and lives_remaining. I need a query that will give me the most recent lives_remaining total for each usr_id There are multiple users (distinct usr_id's) time_stamp is not a unique identifier: sometimes user even...

Is it possible in SQL to match a LIKE from a list of records in a subquery?

Using these tables, as a sample: Table CodeVariations CODE ----------- ABC_012 DEF_024 JKLX048 And table RegisteredCodes CODE AMOUNT -------- ------ ABCM012 5 ABCK012 25 JKLM048 16 Is it possible to write a query to retrieve all rows in RegisteredCodes when CODE matches a pattern in any row of the Cod...

Using boolean expression in order by clause

I have an order by clause that looks like: ( user_id <> ? ), rating DESC, title Where ? is replaced with the current user's id. On postgresql this gives me the ordering I'm looking for i.e. by current user, then highest rating, then title (alphabetically). However on MySQL I get an unclear order current user is neither first nor las...

rename database in psql

Hi, Could anybody help me to rename database in postgresql from the Linux shell " ALTER DATABASE name RENAME TO newname " The above statement doesn't execute ...

What are the pitfalls of setting enable_nestloop to OFF

I have a query in my application that runs very fast when there are large number of rows in my tables. But when the number of rows is a moderate size (neither large nor small) - the same query runs as much as 15 times slower. The explain plan shows that the query on a medium sized data set is using nested loops for its join algorithm...

How do I fix Postgres so it will start after an abrupt shutdown?

Due to a sudden power outage, the PostGres server running on my local machine shut down abruptly. After rebooting, I tried to restart postgres and I get this error: $ pg_ctl -D /usr/local/pgsql/data restart pg_ctl: PID file "/usr/local/pgsql/data/postmaster.pid" does not exist Is server running? starting server anyway server starting $...

Can I selectively create a backup of Postgres database, with only certian tables?

Can I programatically(or whichever way works fine) create the backup of a database, with only the tables I want? I have around 100 tables in my database and I want only 10 tables backup(ofcourse all are interdependant). How can I achieve this? And by the way I have a postgresql database. ...

Is PostgreSQL's Ltree module a good fit for threaded comments?

I'm considering using PostgreSQL's Ltree module in my application to help with threaded comments. I've been eying it for a while to use for threaded comments. I figure it would help with cases where you need to update a node and its children, like when you want to hide a comment and its replies. I'm thinking ltree (or something like...

How do I override the SQL for a CRecordSet and then requery?

I have a CRecordSet (Visual C++ 6.0) and I'm using ODBC to connect to postgresql 8.0.8. __ The problem: I insert a row into a table with a serial id (autoincrement), and I would like to retrieve the id after my insert. I can't use the RETURNING keyword, not supported on this version of PGsql, but I can use currval('sequence'). Howeve...

Installing PL/Ruby for PostgreSQL

This is to enable the development of postgres functions with embedded ruby code, but I have been unable to build it. As advised by http://www.robbyonrails.com/articles/2005/08/22/installing-untrusted-pl-ruby-for-postgresql I am trying to build the needed plruby.so from the latest version (plruby-0.5.3.tar.gz) provided at ftp://moulon...

escaping bracket in postgresql query

I am trying to escape a bracket in a pattern matching expression for PostgreSQL 8.2 The clause looks something like: WHERE field SIMILAR TO '%UPC=\[ R%%(\mLE)%' but I keep getting: ERROR: invalid regular expression: brackets [] not balanced ...

Sqllite coalesce problem when running django testcases

I am using django for running my project. And I am using postgresql_psycopg2 engine for my production db, but the test runner uses sqllite3 for running the tests. Keeping my production db(postgresql)in mind I tried building a query which uses "coalesce". But sqllite3 doesn't recognize this. How do I get pass this. I can use postgresql_ps...

Does Postgres have something similar to Oracle's Virtual Private Databases?

As the title suggests, does anyone know if such a thing exists? ...

Best cross-platform/SQL GUI?

I use SQL Server 2005, MySql, and Posgresql regularly. I'm tired of using Microsoft's SQL tool for SQL Server, phpMyAdmin for MySql, and pgAdmin for Postgres. Is there a decent cross-platform GUI that I can use for all of these database servers? I don't care about the actual database administration part, I realize that each vendor's to...

Best way to learn PostgreSQL stored procedures?

Is there a good tutorial or something similar for learning how to write Stored Procedures (for a PostgreSQL database). I'm a definite newbie when it comes to writing Stored Procedures at all, so the clearer and simpler things are explained, the better... Thanks in advance... ...