Pular para o conteúdo principal

Questão de Banco de Dados — SQL — FGV 2014

Banco de DadosSQL
Código
fg007275
Banca
FGV
Órgão
Câmara Municipal do Recife - PE
Ano
2014
Nível
Superior
Cargo
Câmara Municipal do Recife-PE - Analista de Sistemas
Considere um banco de dados com duas tabelas, T1 e T2, onde:T1 possui duas colunas, A e B;T2 possui duas colunas, A e C;A é a chave primária de T1; A é a chave primária de T2.Considere também o seguinte comando SQL:select t1.a,t1.b,t2.c from t1 left join t2 on t1.a=t2.aorder by t1.aO comando SQL que, para quaisquer instâncias de T1 e T2, produz o mesmo resultado que o comando acima é:
  1. Aselect t1.a,t1.b,t2.cfrom t1 full outer join t2 on t1.a=t2.aorder by t1.a
  2. Bselect t1.a,t1.b,t2.cfrom t1 inner join t2 on t1.a=t2.aunionselect t1.a,t1.b,nullfrom t1 where not exists (select * from t2 where t1.a=t2.a)order by t1.a
  3. Cselect t1.a,t1.b,null c from t1where t1.a in (select a from t2 where t1.a=t2.a)order by t1.a
  4. Dselect t1.a,t1.b,t2.cfrom t1, t2where t1.a <> t2.aorder by t1.a
  5. Eselect t1.a,t1.b,t2.cfrom t1, t2where t1.a=t2.aorder by t1.a
Revelar gabarito e comentário

GabaritoB — select t1.a,t1.b,t2.c from t1 inner join t2 on t1.a=t2.a union select t1.a,t1.b,null from t1 where not exists (select * from t2 where t1.a=t2.a) order by t1.a

Link permanente: /questoes/fg007275