Created
July 25, 2017 16:07
-
-
Save filipececcon/f13be6166ba486e4c2b8ae94dbba29ca to your computer and use it in GitHub Desktop.
initialSQL.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE master; | |
GO | |
--ALTER DATABASE Dapper_DB SET OFFLINE WITH ROLLBACK IMMEDIATE; DROP DATABASE Dapper_DB | |
CREATE DATABASE Dapper_DB; | |
GO | |
USE Dapper_DB; | |
GO | |
DROP TABLE TB_JOGADOR | |
DROP TABLE TB_TIME | |
CREATE TABLE TB_TIME( | |
[ID] [int] IDENTITY(1,1) PRIMARY KEY NOT NULL, | |
[NM_TIME] [varchar](100) NOT NULL, | |
) | |
CREATE TABLE TB_JOGADOR( | |
[ID] [int] IDENTITY(1,1) PRIMARY KEY NOT NULL, | |
[NM_JOGADOR] [varchar](100) NOT NULL, | |
[NR_IDADE] [int] NOT NULL, | |
[ID_TIME] [int] NOT NULL, | |
CONSTRAINT FK_TB_TIME FOREIGN KEY (ID_TIME) REFERENCES TB_TIME(ID) | |
) | |
INSERT INTO TB_TIME (NM_TIME) VALUES ('VERDE'),('AMARELO'),('PRETO'),('AZUL') | |
INSERT INTO TB_JOGADOR (NM_JOGADOR, NR_IDADE, ID_TIME) | |
VALUES | |
('RICARDO', 25, 2), | |
('DOUGLAS', 28, 1), | |
('ROBSON', 35, 3), | |
('FILIPE', 30, 1), | |
('GUSTAVO', 25, 4) | |
--Pode dar um erro no resultset, mas verifique com esse select abaixo se as tabelas foram criadas e populadas | |
SELECT * FROM TB_JOGADOR INNER JOIN TB_TIME ON TB_JOGADOR.ID_TIME = TB_TIME.ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment