Skip to content
Advertisement

Tag: psql

How do I change a text to an enum type?

so basically I want to import a csv file and one of the columns has the data yes/no in it and I have created an enum that has values ‘red’ and ‘white’ and the yes related to ‘red’ in the enum and no relates to ‘white’ in the enum and the column in the table in the database is of

How to fix cache lookup failure/corrupted database?

I’ve got a postgres database that I’m trying to clean up with drop schema public cascade. The data on it is not that important and I never made any backups. I’m just trying to rebuild it. However, it seems an error I made earlier is causing the drop command to fail. When I run drop schema public cascade, I get

Running query against all schemas in Postgres

Context We do schema-based multi-tenancy in our Postgres DB. Each and every schema is associated to a different tenant and will have the exact same structure except for one schema named public. To obtain the list of all the relevant schemas, we can use: Problem We need to periodically clean up a specific table for all the tenants: (The actual

I need to get count of total count for the query I had in postgresql

I created a select query as following, now I need to get the total count of the “No.of Ideas generated” column in a separate row as total which will have a count of the individual count of particular idea_sector and idea_industry combination. Query: Output: Required output: Answer You can accomplish this with grouping sets. That’s where we tell postgres, in

Creating primary key in postgresql takes days

I am trying to write my table to a PostgreSQL database then declare a primary key. My data is really huge (includes billions of rows and total size is approximately 150 GB), when I try to create a primary key after writing the table, it takes forever. Here is how I define the primary key; I am %101 sure about

Advertisement