4
I’m taking an SQL/Modeling course in mysql the creation of a composite table would look like this:
USE banco;
CREATE TABLE clientes(
cli_id integer not null auto_increment,
cli_nome varchar(20) not null,
cli_email varchar(30) not null
primary key (cli_id)
); /*Cria a tabela no mysql*/
Okay, now on Firebird I have to do:
CREATE TABLE clientes(
cli_id integer not null auto_increment,
cli_nome varchar(20) not null,
cli_email varchar(30) not null
primary key (cli_id)
); /*cria a tabela no firebird*/
create generator gen_cidades_id /*Cria gerador auto increment*/
SET TERM ^
CREATE TRIGGER TR_CIDADES FOR CIDADES
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
new.CID_CODIGO =gen_id(ge_cidades_id, 1);
END ^
There is no other way to do the auto_increment in Firebird besides this ? for this part here:
create generator gen_cidades_id /*Cria gerador auto increment*/
SET TERM ^
CREATE TRIGGER TR_CIDADES FOR CIDADES
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
new.CID_CODIGO =gen_id(ge_cidades_id, 1);
END ^
I didn’t understand her and it’s very complicated, in my view.
I believe Mysql also creates a generator and a Trigger, only in an uncompromising way.
– Franchesco
Remembering that "generated by default as Identity" transparently creates a Quence and a Rigger. " id integer generated by default as Identity Primary key"
– Diego Bastos