Doubt with Insert in Postgres Bank

Asked

Viewed 290 times

0

I have an error message, tried several options of not getting a solution. Is there any configuration that is missing?

inserir a descrição da imagem aqui

  • The name field is an array? if it’s gonna keys in it

  • 2

    you solved my problem, I always used sql server and had no idea what kind of field and quite different, I adjusted the field of the database and it worked, I had put a field of type array, did not know that this was possible

  • All postgres fields have an array version, at the time create a view has the char and the char[] for example.

  • value to tip, very grateful

3 answers

1

The name seems to be of type array, in which case it is necessary to inform the correct syntax keys are required.

INSERT INTO empresa (id, nome) VALUES(2, '{teste}')

0

0

I believe that at the time of creating the field you have used Character Varing[] which is an array of varchars (or an array of dynamic strings). The correct field, if you want to create only 1 string, is Character Varing and in the length field the maximum string size.

As for the syntax of Insert, if there is more than one command in the query each of them must end with ";". In your case:

insert into empresa (id,nome) values (2,'teste');
select * from empresa;

But if there are several Inserts one can do the following:

insert into empresa (id,nome) values (1, 'teste1'), (2, 'teste2'), ..., (n, 'testeN');

See on Sqlfiddle

Browser other questions tagged

You are not signed in. Login or sign up in order to post.