Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

208
Visualizações
SQL, add more informations for columns

Ok, I have a problem a bit complicated to explicate and to understand:

I have a postgreSQL DataBase who contains tables with columns, and I want to add some informations about each column, so I make a "service table" who look like this:

+---------------+-----------+--------------------+----------+----------+
| ColumnName    |  ucd      |       utype        | datatype |  table   |
+---------------+-----------+--------------------+----------+----------+
| ident         | ucd:ident | utype:EntityId     | char     | Entity   |
| label         | ucd:label | utype:EntityLabel  | char     | Entity   |
| level         | ucd:level | utype:EntityLevel  | int      | Entity   |
| idAct         | ucd:Acti  | utype:ActivityId   | char     | Activity |
| label         | ucd:label | utype:ActivityLb   | char     | Activity |
| ...           | ...       | ...                | ...      | ...      |
+---------------+-----------+--------------------+----------+----------+

The utype and ucd columns are unique

My problem is:

I do a request on my db.

Exemple: Select * from entity:

Result:

+-------+---------+-------+
| ident |  label  | level |
+-------+---------+-------+
|     1 | Entity1 |     1 |
|     2 | Entity2 |     2 |
|     3 | Entity3 |     2 |
+-------+---------+-------+

I also want to recover all the informations about my columns in my query whit my service table:

Something like this:

Ident: ucd = ucd:ident, utype = utype:EnetityId, datatype=char

Label: ucd = ucd:label, utype = utype:EntityLabel, datatype=char

Level: ucd = ucd:level, utype = utype:EntityLevel, datatype=int

I know how to have all the columns name of the result of my query, but I don't know how to have all the information about them:

I have that:

Select * from servicetable
where columnName = 'queryColumnName'

But columnName is not unique in service table so,it may return more than one row.

I hope you have understand my problem. Thank you

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I really did not understand but I'll try help.

1) You already have some information about tables and columns on postgresql. Example:

SELECT *
FROM information_schema.columns
WHERE table_schema = 'your_schema'
AND table_name   = 'your_table';

2) Why dont you add one more filter like " AND table = 'Entity'" ?

Try explain more about your problem.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda