postgresql-8.4

How to add “on delete cascade” constraints?

柔情痞子 提交于 2019-11-26 21:40:21
In PostgreSQL 8 is it possible to add ON DELETE CASCADES to the both foreign keys in the following table without dropping the latter? # \d scores Table "public.scores" Column | Type | Modifiers ---------+-----------------------+----------- id | character varying(32) | gid | integer | money | integer | not null quit | boolean | last_ip | inet | Foreign-key constraints: "scores_gid_fkey" FOREIGN KEY (gid) REFERENCES games(gid) "scores_id_fkey" FOREIGN KEY (id) REFERENCES users(id) Both referenced tables are below - here: # \d games Table "public.games" Column | Type | Modifiers ----------+------

Change Database Collation, Ctype in Postgresql

牧云@^-^@ 提交于 2019-11-26 21:33:56
问题 how do I change Collation, cType to - en_IN from en_US.UTF-8 List of databases Name | Owner | Encoding | Collation | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres : postgres=CTc/postgres template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres : postgres=CTc/postgres my current

Generating a UUID in Postgres for Insert statement?

妖精的绣舞 提交于 2019-11-26 16:52:32
My question is rather simple. I'm aware of the concept of a UUID and I want to generate one to refer to each 'item' from a 'store' in my DB with. Seems reasonable right? The problem is the following line returns an error: honeydb=# insert into items values( uuid_generate_v4(), 54.321, 31, 'desc 1', 31.94); ERROR: function uuid_generate_v4() does not exist LINE 2: uuid_generate_v4(), 54.321, 31, 'desc 1', 31.94); ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. I've read the page at: http://www.postgresql.org/docs/current/static/uuid-ossp

Select (retrieve) all records from multiple schemas using Postgres

跟風遠走 提交于 2019-11-26 11:34:16
问题 I have a PostgreSQL database with some schemas, like below: My_Database |-> Schemas |-> AccountA |-> AccountB |-> AccountC |-> AccountD |-> AccountE . . . |-> AccountZ All schemas have a table called product which has a column called title . I would like to know if is possible to execute a select statement to retrieve all records from all schemas with a certain conditional. The only way I found until now is to run a query account by account, like below. SET search_path TO AccountA; SELECT

How to add “on delete cascade” constraints?

瘦欲@ 提交于 2019-11-26 07:59:40
问题 In PostgreSQL 8 is it possible to add ON DELETE CASCADES to the both foreign keys in the following table without dropping the latter? # \\d scores Table \"public.scores\" Column | Type | Modifiers ---------+-----------------------+----------- id | character varying(32) | gid | integer | money | integer | not null quit | boolean | last_ip | inet | Foreign-key constraints: \"scores_gid_fkey\" FOREIGN KEY (gid) REFERENCES games(gid) \"scores_id_fkey\" FOREIGN KEY (id) REFERENCES users(id) Both

Generating a UUID in Postgres for Insert statement?

社会主义新天地 提交于 2019-11-26 04:03:21
问题 My question is rather simple. I\'m aware of the concept of a UUID and I want to generate one to refer to each \'item\' from a \'store\' in my DB with. Seems reasonable right? The problem is the following line returns an error: honeydb=# insert into items values( uuid_generate_v4(), 54.321, 31, \'desc 1\', 31.94); ERROR: function uuid_generate_v4() does not exist LINE 2: uuid_generate_v4(), 54.321, 31, \'desc 1\', 31.94); ^ HINT: No function matches the given name and argument types. You might

Split comma separated column data into additional columns

回眸只為那壹抹淺笑 提交于 2019-11-26 00:59:31
问题 I have comma separated data in a column: Column ------- a,b,c,d I want to split the comma separated data into multiple columns to get this output: Column1 Column2 Column3 Column4 ------- ------- ------- ------- a b c d How can this be achieved? 回答1: If the number of fields in the CSV is constant then you could do something like this: select a[1], a[2], a[3], a[4] from ( select regexp_split_to_array('a,b,c,d', ',') ) as dt(a) For example: => select a[1], a[2], a[3], a[4] from (select regexp