0
I’m learning SQL, and my teacher gave me an activity, I did it, but he gave me 1 grade. I want to know if the code is right.
CREATE DATABASE escola;
USE escola;
CREATE TABLE aluno (
codigo INT PRIMARY KEY AUTO_INCREMENT,
nome VARCHAR (50) ,
idade INT,
cpf VARCHAR (15)
);
CREATE TABLE professor(
codigo INT PRIMARY KEY AUTO_INCREMENT,
nome VARCHAR (50),
disciplina VARCHAR (50),
salario DOUBLE
);
INSERT INTO aluno
VALUES (0000000, 'Joao', 13, 01010101011),
(1111111, 'Maria', 18, 02020202020),
(2222222, 'Gabriel', 20, 03030303030),
(3333333, 'Marcos', 30, 04040404040),
(4444444, 'Vitoria', 16, 05050505050);
INSERT INTO professor
VALUES (00000, 'Victor', 'Matemática', 1500),
(01010, 'Joana', 'Português', 2500),
(02020, 'Mario', 'Geografia', 1800),
(03030, 'Daniel', ''Física, 2500),
(04040, 'Juliana', 'Arte', 2300);
UPDATE aluno SET idade = 19 WHERE nome='Maria'
UPDATE professor SET salario = 2300 WHERE nome='Joana'
DELETE FROM aluno WHERE nome='Marcos'
DELETE FROM professor WHERE nome='Juliana'
SELECT * FROM aluno
SELECT * FROM professor
SELECT * FROM aluno WHERE idade>16
SELECT * FROM professor WHERE salario>2000
You tested the code?
– Claudio Lopes
I don’t know if the instructor took it as a mistake, but the names of the bank and the tables he asked for in capital letters. The INSERT is with several errors, to insert values you need to point the field that will receive such value, example: INSERT INTO Student (code, name, age, Cpf) VALUES (0000000, 'Joao', 13, '01010101011'), vc entered Cpf values as integer, but, it is a field of the type SWEEP, finally, when inserting the value
Física
you didn’t put in quotes.– LeAndrade