-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomandos-sql.txt
More file actions
44 lines (41 loc) · 1.29 KB
/
comandos-sql.txt
File metadata and controls
44 lines (41 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
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
# Criando a tabela autor
create table autor(
id uuid not null primary key,
nome varchar(100) not null,
data_nascimento date not null,
nacionalidade varchar(50) not null,
data_cadastro timestamp,
data_atualizacao timestamp,
id_usuario uuid
);
# Criando a tabela livro
create table livro(
id uuid not null primary key,
isbn varchar(20) not null unique,
titulo varchar(150) not null,
data_publicacao date not null,
genero varchar(30) not null,
preco numeric(18, 2),
data_cadastro timestamp,
data_atualizacao timestamp,
id_usuario uuid,
id_autor uuid not null references autor(id)
constraint chk_genero check(genero in ('FICCAO', 'FANTASIA', 'MISTERIO', 'ROMANCE', 'BIOGRAFIA', 'CIENCIA') )
);
# Criando a tabela usuario
create table usuario(
id uuid not null primary key,
login varchar(100) not null unique,
senha varchar(300) not null,
email varchar(150) not null,
roles varchar[]
);
# Criando a tabela client
create table client(
id uuid not null primary key,
client_id varchar(150) not null,
client_secret varchar(400) not null,
redirect_uri varchar(200) not null,
scope varchar(50)
);