create or replace for tables and schemas

Started by Marcelo de Moraes Serpaover 18 years ago3 messagesgeneral
Jump to latest
#1Marcelo de Moraes Serpa
celoserpa@gmail.com

For some weid reason, I can't use a stored function nor return data from
sql, just send sql to the database, that's my constraint for now and I have
to deal with it.

I have to create a schema and just after a table in this schema. I can't
check for the existence of the table nor the schema. If the sql code to
create the table and the schema is ran when the schema and or the table
exist, a sql excepetion is thrown and my application halts.

With this in mind, I'd like to know if there is something like CREATE OR
REPLACE for tables and schemas so that if the object already exists, it will
just replace it.

For those curious, my company uses an application generator called GeneXus,
it has a "sql" "command" which allows you to send direct sql sentences to
the database **as long as** they don't return anything. Oh life.

Anyway, thanks in advance,

Marcelo.

#2Martijn van Oosterhout
kleptog@svana.org
In reply to: Marcelo de Moraes Serpa (#1)
Re: create or replace for tables and schemas

On Mon, Aug 27, 2007 at 08:24:51AM -0300, Marcelo de Moraes Serpa wrote:

With this in mind, I'd like to know if there is something like CREATE OR
REPLACE for tables and schemas so that if the object already exists, it will
just replace it.

Looks lke DROP IF EXISTS was made for you.

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

From each according to his ability. To each according to his ability to litigate.

#3Marcelo de Moraes Serpa
celoserpa@gmail.com
In reply to: Martijn van Oosterhout (#2)
Re: create or replace for tables and schemas

Thanks Martijn

Show quoted text

On 8/27/07, Martijn van Oosterhout <kleptog@svana.org> wrote:

On Mon, Aug 27, 2007 at 08:24:51AM -0300, Marcelo de Moraes Serpa wrote:

With this in mind, I'd like to know if there is something like CREATE OR
REPLACE for tables and schemas so that if the object already exists, it

will

just replace it.

Looks lke DROP IF EXISTS was made for you.

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

From each according to his ability. To each according to his ability to

litigate.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFG0rflIB7bNG8LQkwRAsOZAJ0QyEMaNtMR0Sa1xmuzPDT58So35wCgg8qw
5r27tWKhBnYAkspu34z91Og=
=KhPb
-----END PGP SIGNATURE-----