SóProvas


ID
1389535
Banca
CESPE / CEBRASPE
Órgão
SEGESP-AL
Ano
2013
Provas
Disciplina
Banco de Dados
Assuntos

CREATE TABLE municipio
(
codigoibge7 integer NOT NULL,
municipioibge varchar(50),
coduf integer,
CONSTRAINT pkmunicipios PRIMARY KEY (codigoibge7)
);

CREATE TABLE pessoa
(
codigo integer NOT NULL,
nome varchar(200),
data_nascimento date,
cpf varchar(11),
endereco varchar(200),
bairro varchar(200),
ibge integer,
CONSTRAINT pessoa_pk PRIMARY KEY (codigo),
CONSTRAINT municipio_fk FOREIGN KEY (ibge)
references municipio (codigoibge7)
);

Considerando a expressão SQL99 acima, julgue o item a seguir, acerca de álgebra relacional e SQL.

Os seguintes comandos SQL retornam os mesmos resultados.

select count(*), ibge
from pessoa p, municipio m
where ibge = codigoibge7
group by ibge;

select count(*), ibge
from pessoa p cross join municipio m
where ibge = codigoibge7
group by ibge;

Alternativas
Comentários
  • (from pessoa p, municipio m) E (from pessoa p cross join municipio m) são equivalentes, logo o resultado será igual. 

    SQL CROSS JOIN will return all records where each row from the first table is combined with each row from the second table. Which also mean CROSS JOIN returns the Cartesian product of the sets of rows from the joined tables.

    A CROSS JOIN can be specified in two ways: using the JOIN syntax or by listing the tables in the FROM clause separated by commas without using a WHERE clause to supply join criteria.

    SQL CROSS JOIN syntax:

    SELECT * FROM [TABLE 1] CROSS JOIN [TABLE 2]

    OR

    SELECT * FROM [TABLE 1], [TABLE 2]