-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMySQL.txt
More file actions
50 lines (44 loc) · 1.29 KB
/
MySQL.txt
File metadata and controls
50 lines (44 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Create DataBase SHMDB;
create user 'admin'@'%' identified by '123';
grant all on *.* to 'admin'@'%' with grant option;
flush privileges;
Create Table SHMDB.Users(
IdUser int auto_increment,
NameUser varchar(32) not null,
PasswordUser varchar(32) not null,
AdminUser boolean not null,
primary key(IdUser)
);
Create Table SHMDB.Clientes(
IdCliente int auto_increment,
NomeCliente varchar(128) not null,
EnderecoCliente varchar(256),
TelefoneCliente varchar(14),
primary key(IdCliente)
);
Create Table SHMDB.Produtos(
IdProduto int auto_increment,
NomeProduto varchar(32) not null,
DescricaoProduto varchar(128),
PrecoProduto double not null,
primary key(IdProduto)
);
Create Table SHMDB.Vendas(
IdVenda int auto_increment,
IdCliente int,
DataVenda varchar(10) not null,
DescricaoVenda varchar(512),
PagoVenda boolean,
primary key(IdVenda),
foreign key(IdCliente) references SHMDB.Clientes(IdCliente)
);
Create Table SHMDB.ProdutoVenda(
IdProdutoVenda int auto_increment,
IdVenda int,
IdProduto int,
QuantidadeProdutoVenda int not null,
ValorProdutoVenda double not null,
primary key(IdProdutoVenda),
foreign key(IdVenda) references SHMDB.Vendas(IdVenda),
foreign key(IdProduto) references SHMDB.Produtos(IdProduto)
);