Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create database selects
- go
- use selects
- create table funcionario(
- id int identity not null primary key,
- nome varchar(100) not null,
- sobrenome varchar(200) not null,
- logradouro varchar(200) not null,
- numero int not null CHECK(numero > 0),
- bairro varchar(100) null,
- cep char(8) null CHECK(LEN(cep) = 8),
- ddd char(2) DEFAULT ('11') null,
- telefone char(8) null CHECK(LEN(telefone) = 8),
- data_nasc datetime not null CHECK(data_nasc < GETDATE()),
- salario decimal(7,2) not null)
- create table projeto(
- codigo int not null identity(1001,1) primary key,
- nome varchar(200) not null,
- descricao varchar(300) null)
- create table funcproj(
- id_funcionario int not null,
- codigo_projeto int not null,
- data_inicio datetime not null,
- data_fim datetime not null,
- CONSTRAINT chk_dt CHECK(data_fim > data_inicio),
- primary key (id_funcionario, codigo_projeto),
- foreign key (id_funcionario) references funcionario (id),
- foreign key (codigo_projeto) references projeto (codigo))
- select * from funcionario
- select * from projeto
- select * from funcproj
- insert into funcionario (nome, sobrenome, logradouro, numero, bairro, cep, ddd, telefone, data_nasc, salario) values
- ('Fulano', 'da Silva', 'R. Voluntários da Patria', 8150, 'Santana', '05423110', '11', '76895248', '15/05/1974', 4350.00),
- ('Cicrano', 'De Souza', 'R. Anhaia', 353, 'Barra Funda', '03598770', '11', '99568741', '25/08/1984', 1552.00),
- ('Beltrano', 'Dos Santos', 'R. ABC', 1100, 'Artur Alvim', '05448000', '11', '25639854', '02/06/1963', 2250.00),
- ('Tirano', 'De Souza', 'Avenida Águia de Haia', 4430, 'Artur Alvim', '05448000', NULL, NULL, '15/10/1975', 2804.00)
- insert into projeto values
- ('Implantação de Sistemas','Colocar o sistema no ar'),
- ('Modificação do módulo de cadastro','Modificar CRUD'),
- ('Teste de Sistema de Cadastro',NULL)
- insert into funcproj values
- (1, 1001, '18/04/2015', '30/04/2015'),
- (3, 1001, '18/04/2015', '30/04/2015'),
- (1, 1002, '06/05/2015', '10/05/2015'),
- (2, 1002, '06/05/2015', '10/05/2015'),
- (3, 1003, '11/05/2015', '13/05/2015')
- (3, 1003, '13/05/2015', '11/05/2015')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement