Skip to content
Advertisement

Tag: postgresql

Recreating relation between two tables

I have a 1:1 relation between data that was not an explicit foreign key in the database. E.g. Table 1 has a once, b twice and c once Table 2 also has a once, b twice and c once I want to create a foreign key from Table 1 to Table 2 when the value is the same: Expected Table

PostgreSQL alter column type from DATERANGE to TSTZRANGE and migrate the data

We’re changing a column run_dates (per request) from daterange to tstzrange, a column with a few months of test data. Essentially we want to migrate! I’m running the script below, inspired by postgreSQL alter column data type to timestamp without time zone and I have to admit, my SQL background is basically nothing Unfortunately….. These types don’t naturally translate. and

How I can update one to many relation in Postgres?

Here is my first table question. Questions have many options, so I referring every option row with question_id Now, How can I update both tables in one query? I building an API. The below-given output is for request. The request will response with question details and options for the question. I am able to update question but questions have many

Advertisement