3
Hello.
My problem is basically a popular table in Postgresql with randomly generated data. As the SQL commands are quite extensive I would like to complement this table gradually. The table has the following structure:
------------------------------------------------------
| registro | nome | CPF | localidade | cidade| email|
------------------------------------------------------
To fill the record column I used the following command:
INSERT INTO data SELECT generate_series(100000,999999) AS REGISTRO;
I could for example fill the first two columns with the following command:
INSERT INTO data SELECT generate_series(100000,999999) AS REGISTRO, md5(random()::text) AS NOME
However, as I said, my goal is to divide the commands into parts. I would then like a solution that based on filling the RECORD column I fill the NAME column. That is, if there is a data in RECORD then enter a data in name and so on.
I tried the following:
INSERT INTO data(nome) SELECT REGISTRO, md5(random()::text) AS NOME;
But the following error occurs:
ERROR: column "name" of relation "data" does not exist
Someone knows a way around it?
It seems to be a problem for stored procedures, in which you can by conditionals and loops (pro case of popular)
– Gustavo Fragoso