sqlpostgresqldummy-data

PostgreSQL: Create/Select a fake/dummy column


How would i write a query so that i can generate myself a column with some specific numbers? I would prefer not to be forced to create a table and import from excel, nor insert values (as i have many numbers to put into that column, and i'll have to put lots of parantheses around those values) See picture for reference. Now imagine i have 1000 numbers. I would like to have some query where i could just copy-paste over those numbers. I tried:

enter image description here


Solution

  • For a list of numbers, from some other source, you can use UNNEST():

    SELECT  UNNEST('{1,2,4,6,54,3,900}'::int[]) AS id;
    

    Just replace "1,2,4,6,54,3,900" with your input, and use the comma to separate the values.