Skip to content
Advertisement

Tag: postgresql

Upsert on an array column

I am trying to do an upsert on the array column but I am not able to achieve the following result. Table name settings id primary key unique user_id foreign_key integer unique friends array tags …

postgresql ERROR: syntax error at or near “PRIMARY”

I’m new to PostgreSQL. I’ve been trying to create tables in a database but some queries give weird errors. the first snippet throws a syntax error but when I add “serial” on the problematic column the error is resolved. Should all primary keys auto-increment in PostgreSQL? This works added serial constraint on songplay_id Answer Should all primary keys auto-increment in

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

Advertisement