I want you to forgive me for this post, maybe it's somebody's doubt, but come on ...
I know that the programmer has to master some things, and these things are considered as trívias, for example; Every programmer has to know advanced English not to stay depending on courses but yes Official documentation of a certain technology, every programmer has to know Object Orientation and every programmer has to know the basics of SQL, so ... I do not know of all these things more I am learning moderately the subjects.
I had the habit of creating my MySQL applications, but I have a client who wants to do the system in PostgreSQL anyway, he does not have a conversation, but today I'm out of a job and there are some quick jobs to do, so I'm hugging and I really need your help.
Currently I need to implement the security system of an application, and I need to create some tables with SQL statement, the project I'm doing it already does a lot for me, and creates some tables automatically, I'm using Spring Boot , but the security part is necessary to create the tables through SQL statement, I know how to do without any problem in MySQL database, but in the same way I know how to do in Mysql I do not know how to create the database in PosgreSQL, I am I'm having trouble with syntax errors, and unfortunately I do not have a test database to create the system, I know this is a huge mistake, but I'm going to try to solve this problem further.
I've tried searching Free courses on how to create tables in SQL, but there is very little information on the internet in this regard, of course there is a lot of information in English, but I can not understand why I'm still learning English. The tables are just the ones below, I'm trying to create these tables in PostgreSQL, but it seems that to create an auto increment key I have to create it separately, I've made a few attempts, but I'm afraid that damaging the database settings on the server Heroku.
CREATE TABLE usuario (
codigo BIGINT(20) PRIMARY KEY AUTO_INCREMENT,
nome VARCHAR(50) NOT NULL,
email VARCHAR(50) NOT NULL,
senha VARCHAR(120) NOT NULL,
ativo BOOLEAN DEFAULT true,
data_nascimento DATE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE grupo (
codigo BIGINT(20) PRIMARY KEY,
nome VARCHAR(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE permissao (
codigo BIGINT(20) PRIMARY KEY,
nome VARCHAR(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE usuario_grupo (
codigo_usuario BIGINT(20) NOT NULL,
codigo_grupo BIGINT(20) NOT NULL,
PRIMARY KEY (codigo_usuario, codigo_grupo),
FOREIGN KEY (codigo_usuario) REFERENCES usuario(codigo),
FOREIGN KEY (codigo_grupo) REFERENCES grupo(codigo)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE grupo_permissao (
codigo_grupo BIGINT(20) NOT NULL,
codigo_permissao BIGINT(20) NOT NULL,
PRIMARY KEY (codigo_grupo, codigo_permissao),
FOREIGN KEY (codigo_grupo) REFERENCES grupo(codigo),
FOREIGN KEY (codigo_permissao) REFERENCES permissao(codigo)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Could anyone generously tell me how these tables would look if they were made in PosgreSQL?
When you try to run Query from the user_group creation, you gave the following error;
ERROR: syntax error at or near "("
LINE 2: codigo_usuario BIGINT(20) NOT NULL,
^
********** Error **********
ERROR: syntax error at or near "("
SQL state: 42601
Character: 55