Banco de dadosSql (3)
- (FGV 2022)
Joana trabalha com extração e consolidação de dados e precisa ter acesso aos metadados de um banco de dados SQL Server para compreender melhor o modelo e as estruturas utilizadas. Para começar, Joana resolveu criar uma consulta SQL que produza uma lista das tabelas, com as respectivas colunas com seus tipos de dados e outras propriedades. O comando que Joana deve usar é:
A)
select s1.name tabela, s2.name coluna,
s3.name tipo, s2.iscomputed, s2.isnullable
from sysobjects s1, syscolumns s2, systypes s3
where s1.xtype='T'
and s1.xid=s2.xid and s2.xtype=s3.xtype
and s2.xusertype=s3.xusertype
order by s1.name, s2.name
B)
select s1.name tabela, s2.name coluna,
s3.name tipo, s2.iscomputed, s2.isnullable
from systables s1, syscolumns s2, systypes s3
where s1.xcode=s2.xcode and s2.xtype=s3.xtype
and s2.xusertype=s3.xusertype
order by s1.name, s2.name
C)
select s1.name tabela, s2.name coluna,
s3.name tipo, s3.iscomputed, s3.isnullable
from systables s1, syscolumns s2, systypes s3
where s1.tableid=s2.tableid and s2.xtype=s3.xtype
and s2.xusertype=s3.xusertype
order by s1.name, s2.name
D)
select s1.name tabela, s2.name coluna,
s3.name tipo, s2.iscomputed, s2.isnullable
from sysobjects s1, syscolumns s2, systypes s3
where s1.xtype='U'
and s1.id=s2.id and s2.xtype=s3.xtype
and s2.xusertype=s3.xusertype
order by s1.name, s2.name
E)
select s1.name tabela, s2.name coluna,
s3.name tipo, s2.iscomputed, s2.isnullable
from systables s1, syscolumns s2, sysobjects s3
where s1.xid=s2.xid and s2.xtype=s3.xtype
and s2.xusertype=s3.xusertype
order by s1.name, s2.name
Próximo:
EXERCÍCIOS - Exercício 71
Vamos para o Anterior: Exercício 69
Tente Este: Exercício 14
Primeiro: Exercício 1
VOLTAR ao índice: Banco de dados