Questions tagged as 'postgresql'

1
answer

Passing parameters to procedure in postgresSQL

I will create a trigger in postgreSQL to copy information from one table to another, the tables will always have the same structure, so I want to pass the table names, make a WHILE and copy the files from one to another, but I can not remember...
asked by 17.12.2014 / 13:15
1
answer

Problems with Constraints in PostgreSQL

I'm having a problem with PostgreSQL, 8.1. Adding constraints returns the same error: SQL error:    ERROR: there is no unique constraint matching given keys   referenced table " Here is the code I'm using: CREATE TABLE "adminis...
asked by 14.09.2014 / 20:54
1
answer

Problem with table extension in Postgresql, Person and Physical Person

I'm making an application that has a people register, it's a Person CRUD that can be both physical and legal. the problem is that in my design a Pessoa and a Pessoa Fisica should be created in the database, but it is creating only...
asked by 20.04.2014 / 03:32
2
answers

How to make an auto increment ID relative to another field in PostgreSQL "PostgreSQL"? [duplicate]

id_empresa | id_pedido 1 | 1 1 | 2 1 | 3 1 | 4 2 | 1 2 | 2 3 | 1 I already thought of doing only one trigger and procedure for all the tables, but I do not know how to...
asked by 03.12.2018 / 14:07
3
answers

Is there any difference in these two queries?

Is there any difference in these two querys ? What is the difference between using% in parentheses%? SELECT * FROM produto WHERE grupo = 'bebidas' AND preco < 10 OR estoque <= 100 ORDER BY estoque DESC; SELECT * FROM PRODUTO WHERE grup...
asked by 24.06.2018 / 19:17
1
answer

Rails - BD Relationship

I have a user table, where I have a required field cidade , and I have a contatos table (which is belongs_to: user ), but in the form it does not have the cidade field that is required for user . How do I p...
asked by 15.10.2018 / 17:33
1
answer

How to change the value of the joker in the Prepared Statement?

Suppose I have a query with prepare that looks like this: select senha from usuarios where id=? //or id2=?, array($id,$id2); (é só um exemplo). My intention is to change the ? to any other value that I choose within the array...
asked by 17.02.2014 / 17:55
3
answers

Get all the columns of all the tables that contain a text

I would like to find out what all the columns in the tables in a database are in a way that you can search for a word in those columns. Let's say I have a database that I do not know about the structure, but I want to search for a word in all...
asked by 29.05.2018 / 20:46
1
answer

SQL - Transform different values of a column into several columns with count in each of them

My question is how to separate different values of a column into several columns and give a count on each item according to the name in postgres, follow the example below How are you? --TIPO O.S.--Count----Nome 1009 || 1 || Lucas...
asked by 03.03.2018 / 13:50
3
answers

problem with select case

I'm doing select with case comparing different statuses of the same field and counting them in separate columns. The problem is that the first column gets NULL until the list of the second ends the count. Then this is reversed. My quer...
asked by 31.08.2018 / 14:03