postgresql

not returning anything from postgresql function?

Is it possible for a PostgreSQL plpgsql function to not return anything? I've created a function, and I don't need it to return anything at all, as it performs a complex SQL query, and inserts the results of that query into another table (SELECT INTO ....). Thus, I have no need or interest in having the function return any output or va...

What are some strategies for maintaining a common database schema with a team of developers and no DBA?

I'm curious about how others have approached the problem of maintaining and synchronizing database changes across many (10+) developers without a DBA? What I mean, basically, is that if someone wants to make a change to the database, what are some strategies to doing that? (i.e. I've created a 'Car' model and now I want to apply the appr...

Question about joins and table with Millions of rows

I have to create 2 tables: Magazine ( 10 millions of rows with these columns: id, title, genres, printing, price ) Author ( 180 millions of rows with these columns: id, name, magazine_id ) . Every author can write on ONLY ONE magazine and every magazine has more authors. So if I want to know all authors of Motors Magazine, I have to ...

Installing PostGIS on Windows

I've installed PostgreSQL and PostGIS, and now I'm trying to follow these instructions: http://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#spatialdb-template But I keep getting the following error, both in the command prompt and in Cygwin: C:\Users\Home>createdb -E UTF8 template_postgis createdb: could not connect to databas...

Is there an in memory database that supports the DATE function?

Hi, I am doing some unit testing for a DAO that works with postgresql. Some of the SQL queries that my DAO uses involve the DATE function. Is there an in-memory database that supports functions similar to the ones that postgresql does? Currently I am looking for support for the DATE function however, I obviously can see myself using o...

Regular expression replace in PL/pgSQL

If I have the following input (excluding quotes): "The ancestral territorial imperatives of the trumpeter swan" How can I collapse all multiple spaces to a single space so that the input is transformed to: "The ancestral territorial imperatives of the trumpeter swan" This is going to be used in a trigger function on insert/...

Schemas and tables versus user-ids in a single table using PostgreSQL

I'm developing a web app and I've come to a fork in the road with respect to database structure and I don't know which direction to take. I have a database with user information that I can design one of two ways. The first is to create a schema and a set of tables for each user (duplicating the structure for each user) and the second i...

org.postgresql.util.PSQLException: FATAL: sorry, too many clients already

hi im using postgresql database, I want to insert my datas into database,but whenever i run the server,it was display the following Error. Error:org.postgresql.util.PSQLException: FATAL: sorry, too many clients already How to solve this problem.My server.properties file is following. Sever.properties File: serverPortData=9042 serverP...

Tomcat 5.0.30 and PostgreSQL 8.2 JDK

I have an CentOS 5 server which includes Tomcat 5.0.30 and PostgreSQL 8.2, database includes 15 schemas. Tomcat connects to PostgreSQL via Poolable Connection. My problem is generally one or more a day tomcat shutdown its self. We use same configurations on our other customers but There is no problem. By the way, there is no exception...

Updating records in Postgres using FROM clause

Hi, I'm changing my db schema, and moving column 'seat' from old_table to new_table. First I added a 'seat' column to new_table. Now I'm trying to populate the column with the values from old_table. UPDATE new_table SET seat = seat FROM old_table WHERE old_table.id = new_table.ot_id; This returns ERROR: column reference "seat" is ...

SQL update fields of one table from fields of another one.

I'm having two tables: A [ID, column1, column2, column3] B [ID, column1, column2, column3, column4] A table will always be subset of B table (meaning all columns of A are also in B). I want to update a record with a specific ID in B with their data from A for all columns of A. This ID exists both in A and B. Is there an UPDATE syntax ...

Adding Postgres table cells based on same value

I have a table called expenses. There are numerous columns but the ones involved in my php page are date, spplierinv, amount. I have created a page that lists all the expenses in a given month and totals it at the end. However, each row has a value, but many rows might be on the same supplier invoice.This means adding each row with the s...

postgresql syntax while exists loop

I'm working at function from Joe Celkos book - Trees and Hierarchies in SQL for Smarties I'm trying to delete a subtree from an adjacency list but part my function is not working yet. WHILE EXISTS –– mark leaf nodes (SELECT * FROM OrgChart WHERE boss_emp_nbr = −99999 AND emp_nbr > −99999) LOOP –– get list of next...

Dump to CSV/Postgres memory

I have a large table (300 million lines) that I would like to dump to a csv - I need to do some processing that cannot be done with SQL. Right now I am using Squirrel as a client, and it does not apparently deal very well with large datasets - at least as far as I can tell from my own (limited) experience. If I run the query on the act...

How Do I Update a Table From Another Table Only If the Result Count is 1?

I have a table of 2 tables in a one to many relationship. I want to run an update script that will update the table with the FK of the related table only if there is one result (because if there is multiple then we need to decide which one to use, in another method) Here is what I have so far: UPDATE import_hourly_event_reports i S...

sql newbi - need to copy address_3 from inactive dup record to active address_3

Hi community, I have a table with about 200k addresses. Some are inactive others are active. the inactive ones are duplicates of my active ones. Some of the active ones do not have the address_3 (community names) but the some inactive duplicates do have address_3. I need to being the inactive address_3 into the duplicate match that ...

SQLite and PostgreSql longtext

Hello all, Does anyone know how to change a column in SQLite and PostgreSQL to LONGTEXT? I have done so in MySQL successfully with: "ALTER TABLE projects MODIFY description LONGTEXT;" But this clause doesn't seem to work on SQLite. I tried hard to find documentation on PostgreSQL, but that site's format really makes people puke. SQLi...

Extract data from PostgreSQL DB without using pg_dump

There is a PostgreSQL database on which I only have limited access (e.g, I can't use pg_dump). I am trying to create a local "mirror" by exporting certain tables from the database. I do not have the permissions needed to just dump a table as SQL from within psql. Right now, I just have a Python script that iterates through my table_names...

how to move a postgres schema via file operations ?

Hello, I have a schema schema1 in a postgres database A. I want to have a duplicate of this schema (model + data) in database B under the name schema2. What are my options ? I currently : * dump schema1 from database A * sed my way through schema renaming in the dump : schema1 becomes schema2 * restore schema2 in database B but I ...

PGDATA equivalence for MySQL

Is there an equivalence of ($)PGDATA (Postgres) for MySQL? ...