Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. create database selects
  2. go
  3. use selects
  4.  
  5. create table funcionario(
  6. id int identity not null primary key,
  7. nome varchar(100) not null,
  8. sobrenome varchar(200) not null,
  9. logradouro varchar(200) not null,
  10. numero int not null CHECK(numero > 0),
  11. bairro varchar(100) null,
  12. cep char(8) null CHECK(LEN(cep) = 8),
  13. ddd char(2) DEFAULT ('11') null,
  14. telefone char(8) null CHECK(LEN(telefone) = 8),
  15. data_nasc datetime not null CHECK(data_nasc < GETDATE()),
  16. salario decimal(7,2) not null)
  17.  
  18. create table projeto(
  19. codigo int not null identity(1001,1) primary key,
  20. nome varchar(200) not null,
  21. descricao varchar(300) null)
  22.  
  23. create table funcproj(
  24. id_funcionario int not null,
  25. codigo_projeto int not null,
  26. data_inicio datetime not null,
  27. data_fim datetime not null,
  28. CONSTRAINT chk_dt CHECK(data_fim > data_inicio),
  29. primary key (id_funcionario, codigo_projeto),
  30. foreign key (id_funcionario) references funcionario (id),
  31. foreign key (codigo_projeto) references projeto (codigo))
  32.  
  33. select * from funcionario
  34. select * from projeto
  35. select * from funcproj
  36.  
  37. insert into funcionario (nome, sobrenome, logradouro, numero, bairro, cep, ddd, telefone, data_nasc, salario) values
  38. ('Fulano', 'da Silva', 'R. Voluntários da Patria', 8150, 'Santana', '05423110', '11', '76895248', '15/05/1974', 4350.00),
  39. ('Cicrano', 'De Souza', 'R. Anhaia', 353, 'Barra Funda', '03598770', '11', '99568741', '25/08/1984', 1552.00),
  40. ('Beltrano', 'Dos Santos', 'R. ABC', 1100, 'Artur Alvim', '05448000', '11', '25639854', '02/06/1963', 2250.00),
  41. ('Tirano', 'De Souza', 'Avenida Águia de Haia', 4430, 'Artur Alvim', '05448000', NULL, NULL, '15/10/1975', 2804.00)
  42.  
  43. insert into projeto values
  44. ('Implantação de Sistemas','Colocar o sistema no ar'),
  45. ('Modificação do módulo de cadastro','Modificar CRUD'),
  46. ('Teste de Sistema de Cadastro',NULL)
  47.  
  48. insert into funcproj values
  49. (1, 1001, '18/04/2015', '30/04/2015'),
  50. (3, 1001, '18/04/2015', '30/04/2015'),
  51. (1, 1002, '06/05/2015', '10/05/2015'),
  52. (2, 1002, '06/05/2015', '10/05/2015'),
  53. (3, 1003, '11/05/2015', '13/05/2015')
  54. (3, 1003, '13/05/2015', '11/05/2015')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement