Skip to content
Advertisement

Tag: postgresql

PostgreSQL – Cast generated column type

I tried to create generated column from other JSON type column with ALTER TABLE “Invoice” ADD COLUMN created Integer GENERATED ALWAYS AS (data ->> ‘created’) STORED; When I execute this I get error ERROR: column “created” is of type integer but default expression is of type text HINT: You will need to rewrite or cast the expression. SQL state: 42804

PostgreSQL: Sub-Query on one table

My table looks (simplified) like this: It records filenames “File”; sometimes, a file (here BBB) is replaced by a newer one (here CCC”. First show all records, that have been replaced: OK, brings up line 2. Now I need to add a subquery column QQ, which shows the File of the substitute record, e.g. should bring: . My approach does

Cyrillic symbols in SELECT query PostgreSQL

I have a telegram bot (Aiogram, Python), which is connected to PostgreSQL database. If user enters a some username (in Cyrillic, Russian or Ukrainian), bot should return full information about this user, stored in database. The problem is: when bot making query to the database, with username for example “Сергій”, it returns nothing, although information exists in database. I found

Advertisement