TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

Exercicio

Por:   •  20/6/2015  •  Trabalho acadêmico  •  2.540 Palavras (11 Páginas)  •  160 Visualizações

Página 1 de 11

mysql> create database atv;

Query OK, 1 row affected (0.00 sec)

mysql> use atv;

Database changed

mysql> create table membro(nome varchar(50) not null, telefone int not null, dat

anasc date not null);

Query OK, 0 rows affected (0.27 sec)

mysql> create table projeto(objetivo varchar(50), dataini date, datafim date, cu

sto float );

Query OK, 0 rows affected (0.01 sec)

mysql> create table tipo(descricao varchar(100));

Query OK, 0 rows affected (0.01 sec)

mysql> alter table membro add(cpf varchar(15));

Query OK, 0 rows affected (0.04 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> alter table projeto drop custo;

Query OK, 0 rows affected (0.03 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> desc projeto;

+----------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+----------+-------------+------+-----+---------+-------+

| objetivo | varchar(50) | YES | | NULL | |

| dataini | date | YES | | NULL | |

| datafim | date | YES | | NULL | |

+----------+-------------+------+-----+---------+-------+

3 rows in set (0.00 sec)

mysql> alter table membro add(idmembro int primary key not null auto_increment);

Query OK, 0 rows affected (0.03 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> desc membro;

+----------+-------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+----------+-------------+------+-----+---------+----------------+

| nome | varchar(50) | NO | | NULL | |

| telefone | int(11) | NO | | NULL | |

| datanasc | date | NO | | NULL | |

| cpf | varchar(15) | YES | | NULL | |

| idmembro | int(11) | NO | PRI | NULL | auto_increment |

+----------+-------------+------+-----+---------+----------------+

5 rows in set (0.01 sec)

mysql> alter table projeto add(idprojeto int primary key not null auto_increment);

Query OK, 0 rows affected (0.03 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> alter table tipo add(idtipo int primary key not null auto_increment);

Query OK, 0 rows affected (0.03 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> alter table membro add fktipo int;

Query OK, 0 rows affected (0.04 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> alter table membro add foreign key(fktipo) references membro(idmembro);

Query OK, 0 rows affected (0.43 sec)

Records: 0 Duplicates: 0 Warnings: 0

mysql> desc membro;

+----------+-------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+----------+-------------+------+-----+---------+----------------+

| nome | varchar(50) | NO | | NULL | |

| telefone | int(11) | NO | | NULL | |

| datanasc | date | NO | | NULL | |

| cpf | varchar(15) | YES | | NULL | |

| idmembro | int(11) | NO | PRI | NULL | auto_increment |

| fktipo | int(11) | YES | MUL | NULL | |

+----------+-------------+------+-----+---------+----------------+

6 rows in set (0.01 sec)

mysql> create table cadastro(idcadastro int primary key auto_increment not null,

fkmembro int,fkprojeto int, foreign key (fkmembro) references membro (idmembro)

,foreign key (fkprojeto) references projeto(idprojeto));

Query OK, 0 rows affected (0.02 sec)

mysql> desc cadastro;

+------------+---------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+------------+---------+------+-----+---------+----------------+

| idcadastro | int(11) | NO | PRI | NULL | auto_increment |

| fkmembro | int(11) | YES | MUL | NULL | |

| fkprojeto | int(11) | YES | MUL | NULL | |

+------------+---------+------+-----+---------+----------------+

...

Baixar como (para membros premium)  txt (13 Kb)   pdf (54.2 Kb)   docx (16.8 Kb)  
Continuar por mais 10 páginas »
Disponível apenas no TrabalhosGratuitos.com