postgresql

Show query result column types (PostgreSQL)

Is there a way to easily get the column types of a query result? I read the psql documentation, but I don't think it supports that. Ideally, I'd be able to get something like: columna : text | columnb : integer ----------------+------------------- oh hai | 42 Is there a way I can get this information without...

PostgreSQL 8.4 XML, XSLT and XPath possibilities / documentation.

The available PostgreSQL material on XML, XSLT and XPath is limited. There are the official docs from the PostgreSQL team, however these cover only a few pages of content and I've never been convinced that their docs are as comprehensive as they could be. There are also some bits and bobs on sites kicking around, however there is not to...

How to import a CSV?

I've got a CSV file that looks like this: id, name 0, A.D. TRAMONTANA 1, Abarth 2, Abbot-Detroit 3, AC ... I'm trying to import it into my table via phpPgAdmin. It gives me this error: SQL error: ERROR: column "id, name" of relation "app_vehiclemake" does not exist LINE 1: INSERT INTO "public"."app_vehiclemake" ("id, name") VALUES...

Audit Table DB Design : Does creating Audit Tables for Join Tables make sense

we are creating separate audit tables for those entity tables which need auditing using triggers on PostgreSQL 8.4. <Family> <Contact> <Family_Contact> <Address> We have some join tables. Eg : Family_Contact is a join table. Family has 1 or more than 1 contacts. Each contact has an Address. So, we have the following Table structure....

How do I retroactively make AutoFields that don't break django-admin?

I created the models in a Django app using manage.py inspectdb on an existing postgres database. This seemed to work except that all the primary keys were described in the models as IntegerFields, which made them editable in the admin panel, and had to be hand-entered based on knowledge of the id of the previous record. I just learned ab...

How to configure PostgreSQL to accept all incoming connections

I've got a PostgreSQL data base that I'd like to configure to accept all incoming connections regardless of the source IP address. How can this be configured in the pg_hba.conf file? I'm using postgreSQL version 8.4. ...

PostgreSQL 'Deferrable Delete' still hits constraint on Delete

I want to delete rows from two tables which have a dependence upon each other through a set of deferrable constraints. To simplify this post, I've mocked up a simple DB schema. I'm hoping to remove entries from some table, 'delete_from_me', inside a SQL transaction/DB Patch. The catch is, I want to delete based on a select from a second...

Importing csv file into postgres

Using Mysql Administrator GUI tool - I have exported some data tables retrieved from an sql dumpfile into csv files. I then tried to import these csv files into a postgres database using the postgres COPY command. I've tried entering "COPY articles FROM '[insert .csv dir here]' DELIMITERS ',' CSV;" and also the same command without the ...

Group photos by color

I have a pretty big number of photos and a RGB color map (let's say of about 100 colors). How can I group the pictures by color and obtain something like the following: http://labs.ideeinc.com/multicolr ? My current idea is this: Using ImageMagick, do this for each photo: Resize it to a smaller size so that it can be processed faster....

How to display all the types that i've created using "CREATE TYPE" in postgresql?

HI, this might sound like a silly question but.. i've created several "types" in a database using the CREATE TYPE command, now i'd like to use the same types in a different database in a different server and i didn't save my CREATE TYPE statements. Is there a way to export the types?? or even display the list of types with their fields a...

PostgreSql : Disallow the update of a column : how ?

Hi, Is is possible with PostgreSql without a trigger to not allow the update of a column, just the insertion is allowed. Thanks in advance for your answer. ...

How to debug differences in postgresql TRUNCATE times?

postgres 8.3 / Ubuntu Karmic / 32-bit (in virtualbox): duration: 76.534 ms statement: truncate audit.users cascade duration: 0.952 ms statement: delete from audit.users postgres 8.4 / Ubuntu lucid / 64-bit (native, on the machine hosting the karmic virtualbox): duration: 1469.271 ms statement: truncate audit.users cascade ...

Running M-x sql-postgres in emacs on windows

When I try to run an inferior psql process in emacs on windows, I seem to be getting no response. This seems to be a known problem the solution of which is to install the cygwin version of psql. Unfortunately, the cygwin psql appears to do absolutely nothing, even psql -V does nothing. Does anyone have a solution to either of these pr...

how to view PostgreSQL database on windows 7?

Hi, I installed an application that uses a PostgreSQL database. When I installed the application it automatically installed PostgreSQL for me. How can I view the raw PostgreSQL database rows? Thanks ...

RESOLVED :: Sql question, how to write

Please help me to write the following sql. I have a table like this, with an amount column and date column amount date ----------------------- 100 - 2010-02-05 200 - 2010-02-05 50 - 2010-02-06 10 - 2010-02-06 10 2010-02-07 what I want is to write a sql to get total for each day. Ultimately my query...

PG gem errors on attempting to make connection

I have installed Postgres 8.4.4 via MacPorts per a RobbyOnRails installation guide. When I attempt to connect to a project I get the following error: establish_connection':RuntimeError: Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (dlopen(/Library/Ruby/Gems/1.8/gems/pg-0.9.0/lib/pg_ext.bundle, 9)...

is there a native php function which can escape strings with umlautes correctly for postresql?

Hi, i used the functions pg_escape_bytea() and pg_escape_string() but i had to find out that there are several problems with umlautes: if i do pg_escape_bytea("pöl") , where "pöl" is utf8 i get "p\\303\\266l", and i cannot compare this with my values in the tabels ... so what can i do? have somebody written a function so far, which es...

sql select all for one table only

I have a couple joins that I'm doing. I say tablename.column to identify what I want to select in the database...don't want to select all columns. However, my last join I do want to select all for that. Is there a way I can use an asterisk or something for the last join? The last table is going to be dynamic too so I can't hard code it ...

Special case of updating a column with not null and unique constraints in PostgreSQL

This is a toy example that illustrates a real problem in PostgreSQL. The below examples are using a PostgreSQL 8.4.3 server, but I suspect other versions have the same problem. Given the following table: => create table tmp_foo (foo boolean not null unique, bar boolean not null unique); => insert into tmp_foo (foo, bar) values (true,...

Enforcing uniqueness on PostgreSQL table column after non-unique values already inserted

I already have 80 million records inserted into a table, but need to ensure a few columns are jointly unique. However, the columns already contain non-unique data, so ALTER TABLE doesn't work. I'd like either a query that will let me easily delete records that are non-unique, while keeping one of them, or one that will allow me to load ...