Às tabelas Aluno e Professor, que fazem parte do banco de dados de uma determinada escola e os comandos usados para criar as tabelas, bem como uma instância de cada tabela, são mostrados abaixo.
create table professor
(nome varchar (30) not null,
registro integer not null primary key,
salario decimal (7,2) check (salário > 1000) );
create table aluno
(matricula integer not null,
nome varchar (30) not null,
serie decimal (1) not null,
turno char (1) not null ),
prof integer not null,
primary key (matricula),
foreign key (prof) references professor (registro) );
Professor
| Nome | Registro | Salario |
| Ivo | 11 | 1400,00 |
| Rui | 22 | 2500,00 |
| Carlos | 33 | 2700,00 |
| Mario | 44 | null |
| Katia | 12 | 1300,00 |
Aluno
| Matricula | Nome | Serie | Turno | Prof |
| 10 | Helio | 2 | M | 22 |
| 20 | Duda | 1 | M | 11 |
| 30 | Diogo | 1 | T | 12 |
| 40 | Bernardo | 3 | M | 33 |
| 50 | Fernanda | 2 | M | 22 |
| 60 | Paulo | 3 | T | 33 |
| 70 | Henrique | 3 | T | 33 |
| 80 | Bernardo | 1 | M | 11 |
Analise a atualização SQL que se segue:
update professor
set nome = ‘Sidney’
where aluno.prof = professor.registro
and aluno.serie not in
(select serie
from aluno
where serie < 3 );
Sua execução altera a tabela professor para: