Fórum Como criar uma tabela só se ele não existir? #459287
23/10/2013
0
CREATE TABLE IF NOT EXISTS TABELAX (CAMPO CHAR(1))
Como faço isto no Firebird?
Alessandro Yamasaki
Curtir tópico
+ 0Posts
23/10/2013
Alan Mario
Gostei + 0
23/10/2013
Rafael Cruz
SET TERM !! ;
EXECUTE BLOCK AS
BEGIN
if (not exists(select 1 from RDB$RELATIONS where rdb$relation_name = 'teste')) then
execute statement
'CREATE TABLE teste (
codigo INTEGER NOT NULL,
nome varchar(30) NOT NULL
);';
execute statement 'ALTER TABLE teste ADD CONSTRAINT PK_teste PRIMARY KEY (codigo)';
END!!
SET TERM ; !!
bom código
Gostei + 0
23/10/2013
Alex Lekao
to de olho... rsrs
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)