You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-user@db.apache.org by callme_sanjay <ca...@yahoo.com> on 2007/07/31 14:10:36 UTC
Re: Preventing tables from being dropped
Hello All,
I am facing similar problem ,
Want to update the database but do not want to touch the other tables
Tried the solution mentioned in the "thread" but it;s not working ..
Do I need to any other care while doing it.
Please reply
Regards
-Sanjay
Guido Schreuder-2 wrote:
>
> Hi Tom,
>
> Yep, that'll work, i was thinking along the same line already
>
> thanks,
> Guido
>
> On Sat, 2007-04-14 at 16:58 -0700, Thomas Dudziak wrote:
>> Hi Guido
>>
>> On 4/12/07, Guido Schreuder <g....@xs4all.nl> wrote:
>> > I am looking for a way to prevent tables from being dropped when
>> > executing Platform.alterTables(Database, boolean)
>> >
>> > The reason for this is that my model is iteratively constructed without
>> > prior knowledge of the final model. Currently this will lead to
>> > "unknown" tables being dropped, causing data to be lost.
>> >
>> > An option like would be welcome, but maybe being able to somehow
>> > decorate the SqlBuilder and/or ModelComparator might yield a more
>> > flexible solution. Although the latter would probably not be trivial.
>>
>> Unfortunately, you can't at the moment, at least not out of the box
>> (but a feature request in JIRA would be appreciated).
>> However, you might be able to achieve what you want by using a
>> modified version of e.g. the
>> PlatformImplBase#getAlterTablesSql(Connection, String, String,
>> String[], Database, CreationParameters) method. More precisely, if you
>> do the following:
>>
>> String sql = null;
>> Database currentModel = readModelFromDatabase(connection,
>> desiredModel.getName(), catalog, schema, tableTypes);
>>
>> // Filter the read model here so that only relevant tables are in the
>> currentModel
>>
>> try
>> {
>> StringWriter buffer = new StringWriter();
>>
>> getSqlBuilder().setWriter(buffer);
>> getSqlBuilder().alterDatabase(currentModel, desiredModel, params);
>> sql = buffer.toString();
>> }
>> catch (IOException ex)
>> {
>> // won't happen because we're using a string writer
>> }
>> return sql;
>>
>>
>> The alterTables is nothing more than a wrapper around getAlterTablesSql:
>>
>> Connection connection = borrowConnection();
>>
>> try
>> {
>> return getAlterTablesSql(...);
>> }
>> finally
>> {
>> returnConnection(connection);
>> }
>>
>> hope that helps,
>> Tom
>>
>
>
>
--
View this message in context: http://www.nabble.com/Preventing-tables-from-being-dropped-tf3567482.html#a11922873
Sent from the Apache DdlUtils - User mailing list archive at Nabble.com.