microsoft / microsoft/sql-server-samples

Criação de tabelas

Open
#1,451 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
11.2k
Forks
9.1k
Avg merge
2d 7h
Merged PRs (30d)
14

Description

-- Criação das tabelas
CREATE TABLE Alunos (
IdAluno INT PRIMARY KEY AUTO_INCREMENT,
Nome VARCHAR(100),
Idade INT,
Cidade VARCHAR(100)
);

CREATE TABLE Cursos (
IdCurso INT PRIMARY KEY AUTO_INCREMENT,
NomeCurso VARCHAR(100),
CargaHoraria INT
);

CREATE TABLE Matriculas (
IdMatricula INT PRIMARY KEY AUTO_INCREMENT,
IdAluno INT,
IdCurso INT,
DataMatricula DATE,
FOREIGN KEY (IdAluno) REFERENCES Alunos(IdAluno),
FOREIGN KEY (IdCurso) REFERENCES Cursos(IdCurso)
);

-- Inserção de dados
INSERT INTO Alunos (Nome, Idade, Cidade)
VALUES ('Ana Silva', 20, 'São Paulo'),
('Carlos Souza', 22, 'Santos'),
('Mariana Lima', 19, 'Campinas');

INSERT INTO Cursos (NomeCurso, CargaHoraria)
VALUES ('SQL Básico', 40),
('Programação C#', 60),
('Modelagem de Dados', 30);

INSERT INTO Matriculas (IdAluno, IdCurso, DataMatricula)
VALUES (1, 1, '2025-02-01'),
(2, 3, '2025-02-10'),
(3, 2, '2025-02-12');

-- Consultas
SELECT * FROM Alunos;

SELECT * FROM Cursos;

SELECT A.Nome AS Aluno, C.NomeCurso AS Curso, M.DataMatricula
FROM Matriculas M
JOIN Alunos A ON M.IdAluno = A.IdAluno
JOIN Cursos C ON M.IdCurso = C.IdCurso;

SELECT Nome, Idade FROM Alunos WHERE Idade > 20;

SELECT * FROM Cursos ORDER BY CargaHoraria DESC;

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file, test, or entry point is named. Start by determining whether this SQL script is intended as a new sample and where database samples are organized; the maintainers need to define the target SQL Server compatibility and validation before work can begin.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.