It is possible to save multiple values in a single database field

Asked

Viewed 140 times

3

I declared the field in the database like this:

descricao VARCHAR2(5)not null,

It is possible, for example, to save 1,2,3,4 at once (a single record) in the field descricao, where each of these values refers to a specific thing.

2 answers

2


Yes, it is possible, if the column is varchar You can put whatever text you want into it. But it’s rarely the right thing to do. It may be your case, I don’t know what you want. Of course your application will have to know how to treat it properly always.

If you have 5 values every time, create 5 columns. If it goes from 0 to 5 values, it may be useful to do the same, but it can be considered as waste, some say it is a case for database normalization.

It is also possible to create a varray, but it’s a more advanced topic.

You can do it in C# or any other language that has the ability to access all Oracle resources.

0

An easy and simple way is to use a separator character in the field varchar. example '|' (pipe) and format in SQL in the database and query.

But I do not think it is necessary and do not recommend it. I recommend that you follow the friend’s instructions Maniero

Browser other questions tagged

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