Most voted "postgresql" questions
Postgresql is an open-source, object-relational database management system (ORDBMS) available for many platforms, including Linux, UNIX, MS Windows, and macOS. Please mention your version of Postgresql when asking questions.
Learn more…1,437 questions
Sort by count of
-
3
votes1
answer37
viewsCount twice the number of records from one column to different values using the COUNT(*) function in a single query
I need to count the number of hits and likes per user for different types of content. SCHEMA: secao +--+--------+ |id| nome | +-----------+ |01| Vídeo | |02| Audio | |03| Imagem | |04| Leitura|…
-
3
votes1
answer97
viewsList exiting order while looping
The script below captures the INTERFACE network of a HOST, and inserts into the database (POSTGRES), I swapped the cursor method for a print to check how it was being inserted into the database, and…
-
3
votes1
answer440
viewsInclude date/time field in postgres (Zend)
I have the following code: View: { xtype: 'timefield', name: 'attendance_time', fieldLabel: 'Hora', inputWidth: 100, format: 'H:i', submitFormat: 'H:i', altFormats: 'H:i', } Model: { name:…
-
3
votes1
answer47
viewsShow value 0 when no data is available
To show in an sql query, value 0 when there is no data in the table? SELECT ae.dt_data, to_char(ae.dt_data, 'dy'), case when to_char(ae.dt_data, 'dy') = 'sun' then 'Domingo' when to_char(ae.dt_data,…
-
2
votes1
answer134
viewsHow to change the Prepared Statement wildcard value?
Suppose I have an appointment with prepare that is this way: select senha from usuarios where id=? //or id2=?, array($id,$id2); (é só um exemplo). My intention is to change the ? by any other value…
-
2
votes1
answer601
viewsIs there any way to compress data stored in byte[]?
I get a byte[] which is an image, and saved in the bank (Postgres) in a column o byte[] whole. Can I compress? Make this smaller byte[]?
-
2
votes1
answer291
viewsProblem with table extension in Postgresql, Person and Physical Person
I’m making an application that has a register of people, is a CRUD of Person that can be both physical and legal. the problem is that in my design should be created in the database a Pessoa and a…
-
2
votes1
answer475
viewsSearch for Postgresql similarity
I wonder if I can do a similarity search in a field like character varying in Postgresql. For example: The name I have saved in the table in the name field is Tauros and I’m looking for Taurros. I…
postgresqlasked 10 years, 4 months ago lionbtt 1,211 -
2
votes2
answers135
viewsHow do I sum up the 2-interval difference in Postgresql?
I need to sum up all the gap differences that meet the Where condition. There is only one however, if there is no end_date on this line, I need to take the current time and do the calculation with…
-
2
votes1
answer594
viewsCall to Undefined Function pg_pconnect()
I need to create a connection to a database (already existing) in Postgresql (up and running), using this code (which also existed). Access file_bd.php <?php function conecta() { $ip =…
-
2
votes2
answers1047
viewsUsing timestamp in different fields
I have a timestamp field in a postgres table. I would like to treat, in Delphi, the date in one dbedit and the time in another, is there such a possibility? In the tests I performed, I can change…
-
2
votes1
answer390
viewsHow to get the record total of a table
I need to know how many records there are within my table and add the total find into one variable. I’m doing it this way but it doesn’t work: <?php $w_querybusca = "SELECT * FROM Elem_matr;";…
-
2
votes1
answer1670
viewsPassing parameters to the postgresSQL
I will create a Rigger in postgresql to copy the information from one table to another, the tables will always have the same structure, so I intend to pass the table names, make a WHILE and copy the…
-
2
votes1
answer2762
viewsAdd values from within a column with postgres
I’m trying to sum the values from inside a column with postgres, the table structure is as follows: id |nome_municipio |valores 1 |Porto Alegre |100.01;95.0;50.1 2 |Ivoti |87.0;80.1;45.1 3 |Novo…
-
2
votes2
answers196
viewsError Searching for Serial Postgresql
Using: c#, windows Forms, postgresql I’m having trouble putting together a routine which saves data to a table and retrieves the id recorded(serial / Sequence) and updates the log in another table.…
-
2
votes1
answer84
viewsHow to restrict some BD iterations?
Explaining the title: I have a table called projects, these projects can be approved or disapproved. Each insertion or update of a record in the project table is saved in a history table (e.g.: I…
postgresqlasked 9 years, 10 months ago Lucas Vasconcelos 199 -
2
votes4
answers146
viewssql - SELECT for recent data only
I don’t think my title corresponds to doubt. The application I develop inserts once a month, data referring to the last backup in a table. This table contains the backup instance code, the input…
-
2
votes3
answers458
viewsSearch database table information with PHP every 10 minutes
I need to search for information from a database table every 10 minutes using PHP. Does anyone have any idea how I can do this?
-
2
votes3
answers233
viewsConvert the date format the user types
Hello, I have the following code to format the date that the user informs and inserts in my database: $arrayData['data_validade'] =…
-
2
votes1
answer523
viewsError creating a NOT NULL field in PGADMIN " contains null values "
I have a database already created, within it I have a table already created. In it I need to create a field that is NOT NULL. I do everything by the graphical interface that is faster, I click on…
-
2
votes1
answer63
viewsFetch data from Mysql in Postgresql
Is there any way to connect Mysql with Postgresql, so that Mysql DBMS is used but selecting data that is in Postgresql?
-
2
votes1
answer117
viewsHow to define column types when making a copy for Postgresql
I’m trying to make a copy for a table I have in Postgre, but is giving the following error: ERROR: invalid input syntax for type timestamp: "data_register" I wanted to know how to define that this…
postgresqlasked 9 years, 7 months ago Lucas Vasconcelos 71 -
2
votes1
answer386
viewsI am unable to open a byte array extracted from the database!
Language: C#/ASP.NET Database: Postgreesql Component used for file upload: Fileupload Below is the component: Below is the method to perform the insertion to a table in the database that only has…
-
2
votes1
answer1180
viewsDoubt with backup postgres?
I have on the same machine a Postgresql 9.0 server and also a Postgresql 9.4, I have a database in this latest version, when I try to make a backup I have the following error, as it could solve this…
postgresqlasked 9 years, 6 months ago Harry 3,805 -
2
votes1
answer1250
viewsHow to search for similar words or synonyms in Postgresql
I need to get a survey to return similar words I found the phonetic research it can even be used to refine the search I need, but I think this is not ideal. For example, in a database I have several…
-
2
votes4
answers504
viewsFilter numbers not yet registered via SQL
I’m trying to find the numbers that haven’t been entered in the bank yet. I have a client table, in it I have the fields codigo and nome. When the user registers the client, he puts the code…
-
2
votes2
answers182
viewsHow to return dates with a zero count
I’m trying to use the function coalesce to return 0 when my query does not have a return value, but I have tried a thousand and one ways and I cannot return 0 at all. I want to know where I’m going…
-
2
votes1
answer248
views"create temp table" in Rigger in Postgresql
It is possible to create an Insert Trigger in a "Table1" using "CREATE TEMP TABLE" in its structure and feed a "Table2"?
-
2
votes2
answers1487
viewsHow to round age with Postgresql?
I used the function age(), below, to calculate age, from a date stored in a table: select pessoa.*, age(data_nascimento) from pessoa; Returned the range: 27 years 9 months 9 days It is possible to…
-
2
votes1
answer793
viewsAccess to Database using Java
How do I access a database (I’m using Postgresql) through Java? I’ve seen a way that uses objects like Connection and PreparedStatement. [link] Can someone explain to me about these objects or give…
-
2
votes3
answers451
viewsExchange Postgresql connection for Mysql connection
I found a project made in PHP OO to be used in Postgresql with this connection. <?php class BD { public function __construct() { pg_connect("host=localhost port=5432 user=usuario password=senha…
-
2
votes1
answer128
viewsHow do I restore a database from postgres logs?
I have the database logs I get through the commands pg_start_backupand pg_stop_backup. I wonder how do I restore the bank through them? Thank you!
-
2
votes1
answer199
viewsIs there any tool that makes it possible to create an API using my database?
I have a database all modeled and with a mass of data, now I need to develop an application that provides through a REST API this database. I have two development fronts, the frontend and the…
-
2
votes1
answer604
viewsSql - postgres - Arbitrary accuracy ::
How arbitrary precision works when defining the column as numeric?
-
2
votes2
answers658
viewsProblem writing data to Postgres
I have two tables in postgres (PRODUCT and CATEGORY) In the PRODUCT table I have the FIELDS -> ID, product name, description, value, Id_categoria. In the CATEGORY table I have the FIELDS ->…
-
2
votes5
answers9719
viewsCopy data from one database to another postgress
How do I copy data from a database table to another database table in postgress It’s possible to do something like? INSERT INTO V(ID,D,S) VALUES(SELECT ID,D,S FROM D.A)…
postgresqlasked 9 years ago usersantos 765 -
2
votes1
answer49
viewsPersistence with Doctrine does not take Object data to Insert
I started a new PHP project where every database has tables and their columns with different class names and attributes. With the intention of winning in the productivity of not being renamed I…
-
2
votes3
answers7687
viewsDelete duplicate record from table in Postgresql
Situation Currently I performed a process twice in which it should be processed only once. So my table was populated twice with the same data. tb_kardex cd_kardex | cd_item tb_kardex | 1 | 45875 | |…
-
2
votes2
answers319
viewsField Size Error when running Insert in Postgresql in Delphi application
I have a problem that could only be happening on a Friday #13. I have an application in Delphi that controls SEDEX submissions and use the Postgresql database. In a given column, called sdx_cepnet,…
-
2
votes1
answer105
viewsResult update from another table
I have the following SQL: SELECT id_grade ,MAX(data_lancamento) FROM faturamento_produtos WHERE data_lancamento < '01-01-2010' GROUP BY id_grade Where it only searches for what was released…
-
2
votes1
answer78
viewsJava - How to validate user group in SQL and Save result?
Good morning, I have the following code in Java Desktop. I wanted to know how I can capture this user’s group and save it into a variable. Since when it returns the value and stores in the variable…
-
2
votes3
answers218
viewsPossibility to create 200 columns in a database
I am planning a software, which is a test of 200 questions where each question can only have 3 choices and select only one of them, and each question belongs to a class type ( for example question 5…
-
2
votes1
answer1010
viewsPostgresql syntax error using keys
I’m having trouble understanding why pgadmin is pointing syntax error in my query. select first_name, coalesce(to_char(avg(p.amount),'99.99'), 'nnn') valor_medio from { select c.first_name as…
-
2
votes3
answers1598
viewsHow to create a FUNCTION to format currency in POSTGRE?
I created one, but it didn’t work out: CREATE FUNCTION formatar_moeda(valor FLOAT) RETURNS VARCHAR(15) AS $$ DECLARE formatado VARCHAR(15); BEGIN SET formatado = NUMBER(valor,2); SET formatado =…
postgresqlasked 8 years, 6 months ago Tiago Souza 21 -
2
votes2
answers754
viewsHow to change the last 100 table records in the Postgresql database?
I need to change a table field in my database to perform some tests, and would like to update only the last 100 table records. I’ve tried that code: UPDATE titulo SET autorizado='S' ORDER BY…
-
2
votes1
answer177
viewsSum data with database values. Cakephp 3.0
I need to do a calculation that sums an integer to a date. This integer refers to days. $user = TableRegistry::get('PoliticaSenha'); $query = $user->find()->where(['id' =>…
-
2
votes2
answers411
viewsWhere in integer field[] Postgresql
I am creating a select where I need to check in one of the columns that is of type integer[] if it has one of the values passed in the condition. for example: idTarefa | Setores 1 | {1,3,4} 2 | {2}…
-
2
votes1
answer470
viewsPSYCOPG2 - Pagination
In the search for how to make paging using psycopg2 I discovered the attributes cursor itersize. and cursor., and the methodscursor.fetchmany() and scroll cursor.() I wanted to check with the staff…
-
2
votes2
answers574
viewsPostgresql query without data return
See the following SQL code: SELECT * FROM venda ve WHERE ve.datavenda <= DATE '28/08/2016' In the database you have the following data: The above SQL query is not returning any results, why?…
-
2
votes1
answer377
viewsRelation N-to-N - How to join two fields in a Postgresql record -
In a N-to-N relationship I have three tables "book", "author" and "author book". The following data and structures: tblLivro: id_livro | nomelivro '1' ; 'O Cortiço' '2' ; 'O mulato' '3' ; 'Quimica…