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

Banco de dados

Por:   •  17/1/2016  •  Exam  •  706 Palavras (3 Páginas)  •  295 Visualizações

Página 1 de 3

create table produtos

( codprod int not null auto_increment,

precovenda float not null,

precocusto float not null,

descprod varchar(1000) not null,

quantestoque int not null,

estoquemin int not null,

primary key(codprod)

);

create table andressa_gularte_flores_machado.categorias

( codcategoria int not null auto_increment,

desccategoria varchar(1000) not null,

primary key(codcategoria)

);

create table andressa_gularte_flores_machado.marcas

( codmarcas int not null auto_increment,

descmarcas varchar(1000) not null,

primary key(codmarcas)

);

create table andressa_gularte_flores_machado.unidade

( codunidade int not null auto_increment,

descunidade varchar(1000) not null,

primary key(codunidade)

);

alter table produtos add categoria int not null;

alter table produtos add unidade int not null;

alter table produtos add marcas int not null;

ALTER TABLE produtos ADD CONSTRAINT categoria_fk FOREIGN KEY ( categoria) REFERENCES categorias (codcategoria) ;

ALTER TABLE produtos ADD CONSTRAINT unidade_fk FOREIGN KEY (unidade) REFERENCES unidade (codunidade) ;

ALTER TABLE produtos ADD CONSTRAINT marcas_fk FOREIGN KEY (marcas) REFERENCES marcas (codmarcas) ;

INSERT INTO andressa_gularte_flores_machado.produtos(precovenda,precocusto,descprod,quantestoque,estoquemin) VALUES (29.90, 19.00, "1kg, 30 cm x 30 cm, branco",15,10);

INSERT INTO andressa_gularte_flores_machado.marcas(descmarcas) VALUES ("blablabla

4) alterar os dados da table produtos

update produtos set estoquemin=10 where codprod!=0;

SELECTS

select * from tabela;

select * from categorias where desc_categorias <= enlatados;

select * from categorias order by desc_categorias DESC ou ASC;

(descendente ascendente em ordem alfabética)

select * from categorias where desc_categorias = 1000;

select * from categorias where desc_categorias like 'b%';(selecionar todos os dados da coluno que começam com b)

select * from categorias where desc_categorias like '%s';(selecionar todos os dados da coluno que terminam com s)

select * from categorias where desc_categorias like '%a%':(selecionar todos os dado que tenham a)

ex 1:

crie uma pesquisa que mostrem todos os dados que comecem com a letra b em ordem decrescente

select * from categorias where desc_categorias like 'b%' order by desc_categorias desc

ex2:

crie uma pesquisa que mostre todos os dados que terminam com a letra s snedo ordenados em ordem decrescente pelo código das categorias

select * from categorias where desc_categorias like '%s' order by cod_categorias desc

cire uma pesquisa que mostre todos os dados que contenham a letra a na coluna desc_categorias, sendo ordenados pelo codigo de categorias de forma crescente.

select * from categorias where desc_categorias like '%a%' order by cod_categorias asc

folha

2)

select banda,componentes from artistas order by banda asc;

3)

select banda,datacadastro from artista order by datacadastro desc;

4)

select * from musicas where codigoartista=0158;

5)

select nome,codigoartista from musicas;

6)

select numero,nome,tempo from musicas where codigoartista=0654 order by codigoartista asc;

7)

select nome from musicas where codigoartista=541;

8)

select nome from musicas order by nome asc;

9)

select banda from artista where cidade='Montevideo';

10)

select banda from artista where banda like '%a%';

11)

select banda from

...

Baixar como (para membros premium)  txt (5.9 Kb)   pdf (69.7 Kb)   docx (12.5 Kb)  
Continuar por mais 2 páginas »
Disponível apenas no TrabalhosGratuitos.com