postgresql-9.2

Size limit of JSON data type in PostgreSQL

落爺英雄遲暮 提交于 2019-11-30 02:41:15
Does anyone know what is the limit on the size of JSON data type in PostgreSQL 9.2? Looking at the source for PostgreSQL 9.2.1: Source: postgresql-9.2.1\src\backend\utils\adt\json.c: /* * Input. */ Datum json_in(PG_FUNCTION_ARGS) { char *text = PG_GETARG_CSTRING(0); json_validate_cstring(text); /* Internal representation is the same as text, for now */ PG_RETURN_TEXT_P(cstring_to_text(text)); } Update for PostgreSQL 9.3.5: The code has changed in the json_in function, but the json internal representation is still text: Source: postgresql-9.3.5\src\backend\utils\adt\json.c: /* * Input. */ Datum

Postgres log file contains: missing chunk number 0 for toast value 815441 in pg_toast_2619

十年热恋 提交于 2019-11-29 23:55:51
问题 Below log message is available in postgres log file several thousand times. How to resolve. missing chunk number 0 for toast value 815441 in pg_toast_2619. pg_toast_2619 is the pg_statistic table. it (pg_statistic) contains duplicated records also. How to resolve this situation. What is the reason behind this. 回答1: Something went wrong with you server. Server crashed? Disk failure? Anyway you could do: Stop your server and make a physical copy of your data directory to a secure place; Since

PostgreSql INSERT FROM SELECT RETURNING ID

谁都会走 提交于 2019-11-29 22:49:05
In PostgreSql 9.2.4 I have two tables: user (id, login, password, name) and dealer (id, user_id) . And I want to insert into both tables returning id of created dealer. Currently I'm doing it with two queries: WITH rows AS ( INSERT INTO "user" (login, password, name) VALUES ('dealer1', 'jygbjybk', 'Dealer 1') RETURNING id ) INSERT INTO dealer (user_id) SELECT id FROM rows; SELECT currval('dealer_id_seq'); But can I implement this with a single INSERT query using RETURNING statement? You just need to add a RETURNING id to your INSERT ... SELECT : WITH rows AS (...) INSERT INTO dealer (user_id)

Connecting PostgreSQL 9.2.1 with Hibernate

岁酱吖の 提交于 2019-11-29 20:06:49
I have a blank Spring MVC project, and I've installed Hibernate and the PostgreSQL drivers using Maven. I'm running short on complete tutorials that show how to connect PostgreSQL with Hibernate. Any help here? This is a hibernate.cfg.xml for posgresql and it will help you with basic hibernate configurations for posgresql. <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect<

PostgreSQL query to list all table names?

微笑、不失礼 提交于 2019-11-29 19:06:40
Is there any query available to list all tables in my Postgres DB. I tried out one query like: SELECT table_name FROM information_schema.tables WHERE table_schema='public' But this query returns views also. How can i get only table names only, not views? What bout this query (based on the description from manual )? SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE'; If you want list of database SELECT datname FROM pg_database WHERE datistemplate = false; If you want list of tables from current pg installation of all databases SELECT table

Export and import table dump (.sql) using pgAdmin

橙三吉。 提交于 2019-11-29 18:55:01
I have pgAdmin version 1.16.1 So, for exporting table dumm I do: Right click on table, then in menu click on backup , then in Format choice Plain and save file as some_name.sql Then I remove table. Ok, now I need import table backup some_name.sql into database. How to do this? I can't find how to import table's .sql dump into database using pgAdmin. Can you help me please? In pgAdmin, select the required target scheme in object tree Click on Plugins/PSQL Console Write \i /path/to/yourfile.sql Press enter Using PgAdmin step 1: select schema and right click and go to Backup.. step 2: Give the

Postgresql - unable to drop database because of some auto connections to DB

橙三吉。 提交于 2019-11-29 18:45:33
Whenever I try to drop database I get: ERROR: database "pilot" is being accessed by other users DETAIL: There is 1 other session using the database. When I use: SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'TARGET_DB'; I terminated the connection from that DB, but if I try to drop database after that somehow someone automatically connects to that database and gives this error. What could be doing that? No one uses this database, except me. You can prevent future connections: REVOKE CONNECT ON DATABASE thedb FROM public; (and possibly

How to Auto Increment Alpha-Numeric value in postgresql?

喜夏-厌秋 提交于 2019-11-29 14:46:16
问题 I am using "PostgreSQL 9.3.5" I have a Table ( StackOverflowTable ) with columns (SoId,SoName,SoDob) . I want a Sequence generator for column SoId which is a Alpha-numeric value. I want to auto increment a Alpha-Numeric Value in postgresql. For eg : SO10001, SO10002, SO10003.....SO99999. Edit: If tomorrow i need to generate a Sequence which can be as SO1000E100, SO1000E101,... and which has a good performance. Then what is the best solution! 回答1: Use sequences and default value for id:

The local psql command could not be located

一笑奈何 提交于 2019-11-29 13:16:57
I'm following the instructions found here. When I try to run $ heroku pg:psql or $ heroku pg:psql HEROKU POSTGRESQL_BROWN I recieve the following error message: ! The local psql command could not be located ! For help installing psql, see local-postgresql I can't find anything useful on the link it gives me (it just links to the instructions I was already using, but further down the page) nor can I find this error anywhere else. If I've missed anything you need to know to answer this, just let me know. I'm rather new to all this and teaching myself as I go. I had same error even after

How to return only work time from reservations in PostgreSql?

限于喜欢 提交于 2019-11-29 07:36:54
Select from great answer in How to find first free time in reservations table in PostgreSql create table reservation (during tsrange, EXCLUDE USING gist (during WITH &&) ); is used to find gaps in schedule starting at given date and hour (2012-11-17 8: in sample below) It finds saturday, sunday and public holidays also. Public holidays are defined in table create table pyha ( pyha date primary key) How to exclude weekends and public holidays also? Hard-coding free time as reserved to query like with gaps as ( select upper(during) as start, lead(lower(during),1,upper(during)) over (ORDER BY