Flyway exception with flyway.clean() - Can't drop without CASCADE specification - flyway

While using flyway.clean() -
I get the following error:
Message : SAP DBTech JDBC: [417]: can't drop without CASCADE
specification: cannot drop table referenced by foreign key.
Is there a way to make Flyway cascade drop all objects?

This sounds like a bug. Please file an issue in the issue tracker including the smallest possible bit of SQL that triggers this.

If you want to drop tables that have foreign key constraints on SAP HANA you either have to drop those constraints before or you have to specify the CASCADE command option.
This is documented in the SAP HANA SQL reference guide.
Note, that CASCADE will drop all dependent objects, not just constraints.

Related

MariaDB remove foreign key to temporary table

Context:
I'm trying to upgrade a concrete5 installation from version 8.3.2 to 8.4.1. The upgrade process fails during execution of this SQL statement:
ALTER TABLE AreaLayoutsUsingPresets ADD CONSTRAINT FK_7A9049A1385521EA FOREIGN KEY (arLayoutID) REFERENCES AreaLayouts (arLayoutID) ON UPDATE CASCADE ON DELETE CASCADE
With:
SQLSTATE[HY000]: General error: 1005 Can't create table `concrete5`.`#sql-215_264a4` (errno: 121 "Duplicate key on write or update")
Investigating my database revealed that in information_schema in INNODB_SYS_FOREIGN there is the following entry:
ID FOR_NAME REF_NAME N_COLS TYPE
concrete5/FK_7A9049A1385521EA concrete5/#sql-215_26264 concrete5/AreaLayouts 1 5
Problem:
Now my understanding is, that I cannot modify the information_schema as it isn't a database but just a tabular representation of the system.
I'm wondering how do I get rid of that foreign key entry. The table concrete5/#sql-215_26264 does not exist (I can't find it on my server, nor does alter table or drop table find that table (I've tried with #mysql50# prefix and without it)). So the straight forward way of alter table to drop the foreign key fails because it can't find the table.
I guess I could mess with the upgrade script so that it creates a new foreign key ID, but I'd rather get rid of that zombie in my database. I've already tried to disable the foreign key checks, which then resulted in an error, telling me that the key cannot be added to the system tables (because it's already in there).
Reinstalling is rarely a cure for anything; but I am glad that it fixed your situation.
Table names such as #sql_... usually come from crashing in the middle of an ALTER or similar DDL. Such files can be removed. information_schema is derived from looking at the files, so I think removing the files will kill the zombie entries.
either prefix the SQL import with SET FOREIGN_KEY_CHECKS=0;
or your append it to your query ALTER TABLE...DISABLE KEYS;
... and better dump the whole database before messing around.

Creating DMF error by Wizard

I'm creating a DMF to populate the AX Standard Table SmmSalesUnit.
But when I launch the standard AX Wizard to create a DMF Iget an error To a foreign key constraint it is only possible to add a constraint related to fixed field
I have this standard relation and this
How can I by-pass the problem?
Thanks,
Enjoy.
It is a bug in the data import/export framework. As a workaround you can comment the following line in method generate of class DMFGenerateEntityTable and uncomment it after generation

How to emulate ON DELETE CASCADE?

Is there a way I can emulate the constraints ON DELETE CASCADE in Vertica ?
I seem to get the following error :
ROLLBACK 4229: ON DELETE actions other than NO ACTION are not supported for foreign key constraints
And I cannot find too much about it in the docs!
IIRC foreign key constraints are only enforced for pre-join projections, if you create one of those then the cascade may take place.

Need help for SQLite Database

I am using SQLite for my application. when I used truncate command in SQLite it gives me error like " syntax Error near truncate".
Can anyone help me to solve this problem or any other alternative of truncate except DELETE command.
Why not DELETE?
DELETE with an empty WHERE clause should be pretty fast in SQLite because it does sth called "truncate optimization", see
http://www.sqlite.org/lang_delete.html
SQLite DELETE FROM is not equivalent to T-SQL TRUNCATE TABLE.
SQLite DELETE FROM will not reset the index in a field marked autoincrement.
The SQLLite Delete Truncation Optimization DELETE FROM {table}; (with no WHERE clause) has similar behaviour to the SQL Server TRUNCATE TABLE {table};. See the SQLLite documentation here
The Truncate Optimization
When the WHERE is omitted from a DELETE statement and the table being deleted has no triggers, SQLite uses an optimization to erase the entire table content without having to visit each row of the table individually. This "truncate" optimization makes the delete run much faster. Prior to SQLite version 3.6.5 (2008-11-12), the truncate optimization also meant that the sqlite3_changes() and sqlite3_total_changes() interfaces and the count_changes pragma will not actually return the number of deleted rows. That problem has been fixed as of version 3.6.5 (2008-11-12).
The truncate optimization can be permanently disabled for all queries by recompiling SQLite with the SQLITE_OMIT_TRUNCATE_OPTIMIZATION compile-time switch.
There is none.
Just use DELETE without any arguments.
This is how it is implemented by Drupal 7's database abstraction layer:
http://api.drupal.org/api/drupal/includes--database--sqlite--query.inc/function/TruncateQuery_sqlite%3A%3A__toString/7

Sqlite: How do I reset all database tables?

I want a debug function to do this, but I'm unaware of whether one already exists. Going through and using 'drop table' for each of my tables will be a pain.
Help appreciated.
Since the database is just one file, you can indeed just erase it. If you want something more automatic, you can use the following to do it all programmatically:
Recover your schema:
SELECT group_concat(sql,';') FROM sqlite_master;
Disconnect from the database
Delete the database file
Create your schema again with what was returned from the above query
If you used any particular options for your original database (page_size, etc), they will have to be declared manually as well.
to "drop database" for sqlite, simply delete the database file (and recreate if needed)

Resources