Questions tagged [postgresql-9.1]

for PostgreSQL questions specific to version 9.1.

PostgreSQL 9.1 is the version of PostgreSQL released in September of 2011, with expected end-of-life in September of 2016.

While the generic tag should probably be used with all PostgreSQL-related questions, this tag should also be used if the question pertains to features added in version 9.1, or if the question is about a problem seen while running version 9.1.

1821 questions
45
votes
4 answers

How to determine the OID of a Postgres table?

Does anyone know how to find the OID of a table in Postgres 9.1? I am writing an update script that needs to test for the existence of a column in a table before it tries to add the column. This is to prevent errors when running the script…
Tony Vitabile
  • 8,298
  • 15
  • 67
  • 123
42
votes
3 answers

How to define and use JSON data type in Eloquent?

How can I define JSON data type that is provided in pgsql 9.4 in Laravel 5? I need to define data type, storing and fetching data and so far could not find way to deal it in Laravel 5.1
Volatil3
  • 14,253
  • 38
  • 134
  • 263
42
votes
6 answers

How does autoIncrement work in NodeJs's Sequelize?

Sequelize's document doesn't say a whole lot about autoIncrement. It only includes the following example: // autoIncrement can be used to create auto_incrementing integer columns incrementMe: { type: Sequelize.INTEGER, autoIncrement: true } Based…
Eric H.
  • 6,894
  • 8
  • 43
  • 62
40
votes
3 answers

How to create a enum field with default value?

types = { # add your custom types here 'attendance': ('Notconfirmed','Coming', 'Notcoming', 'Maycome',), } CREATE TYPE attendance AS ENUM types; The above query creates enum type attendance with enumlabels mentioned in…
RaviKiran
  • 753
  • 1
  • 6
  • 13
40
votes
1 answer

What are the pros and cons for choosing a character varying data type for primary key in SQL?

In the databases course that I did during my education (approx. 4 years ago), I thought that it is recommended avoiding the use of character strings as primary key's data type. Can someone tell me what are the pros and cons for choosing a character…
artaxerxe
  • 6,281
  • 21
  • 68
  • 106
39
votes
3 answers

Add primary key to PostgreSQL table only if it does not exist

I have simple table creating script in Postgres 9.1. I need it to create the table with 2-attributes PK only if it does not exist. CREATE TABLE IF NOT EXISTS "mail_app_recipients" ( "id_draft" Integer NOT NULL, "id_person" Integer NOT…
Pavel S.
  • 11,892
  • 18
  • 75
  • 113
39
votes
10 answers

Select query with offset limit is much too slow

I have read from Internet resources that a query will be slow when the offset increases. But in my case I think its much too slow. I am using postgres 9.3. Here is the query (id is primary key): select * from test_table offset 3900000 limit 100; It…
Sabuj Hassan
  • 38,281
  • 14
  • 75
  • 85
39
votes
5 answers

How to duplicate schemas in PostgreSQL

I have a database with schema public and schema_A. I need to create a new schema schema_b with the same structure than schema_a. I found the function below, the problem is that it does not copy the foreign key constraints. CREATE OR REPLACE…
39
votes
5 answers

How to perform a select query in a DO block?

I want to port the below SQL code from MS SQL-Server to PostgreSQL. DECLARE @iStartYear integer DECLARE @iStartMonth integer DECLARE @iEndYear integer DECLARE @iEndMonth integer SET @iStartYear = 2012 SET @iStartMonth = 4 SET @iEndYear = 2016 SET…
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
39
votes
2 answers

Is there a "pg_restore --quiet" option like "psql --quiet"?

psql has a -q / --quiet option (environment variable QUIET). pg_restore does not have a quiet option. Is there any way to make pg_restore not verbosely show the SQL commands that it's executing? # e.g., here's the verbose output that I don't want…
Rob Bednark
  • 25,981
  • 23
  • 80
  • 125
37
votes
2 answers

Error when creating unaccent extension on PostgreSQL

I am trying to configure PostgreSQL to use fulltext search in my rails app as mentioned in this Railscast. I am using a fresh Ubuntu 12.04 server running PostgreSQL 9.1.5 installed using apt-get with the ppa:pitti/postgresql with precise. I get the…
37
votes
2 answers

Is there data visualisation tool for postgresql which is capable of displaying inter schema relations as well?

Operating system used is linux. I have tried Navicat and SQL Power Architect. They did display relations between tables in the same schema. I have some foreign key constraints which reference tables in a different schema. Am I missing something…
36
votes
1 answer

SELECT .. INTO to create a table in PL/pgSQL

I want to use SELECT INTO to make a temporary table in one of my functions. SELECT INTO works in SQL but not PL/pgSQL. This statement creates a table called mytable (If orig_table exists as a relation): SELECT * INTO TEMP TABLE mytable FROM…
nnyby
  • 4,748
  • 10
  • 49
  • 105
35
votes
2 answers

How to take backup of functions only in Postgres

I want to take backup of all functions in my postgres database.How to take backup of functions only in Postgres?
vmb
  • 2,878
  • 15
  • 60
  • 90
35
votes
1 answer

PostgreSQL - dynamic value as table name

Possible Duplicate: Postgres Dynamic Query Function I wish to use the returned string from the query below as a table name for other query. SELECT 'backup_' || TO_CHAR(CURRENT_DATE,'yyyy-mm-dd') as you can see it returns a string. I wish to use…
Mr.
  • 9,429
  • 13
  • 58
  • 82