I am encountering a problem with getting the unit tests to run on
Sybase because of cascades of errors originating from failure to drop
a table that is referenced by a FK constraint in another table. When
attempting to drop the people table, I need the SybaseSQLSchemaDropper
to emit SQL like this which first does an ALTER TABLE to remove FK
constraints from all tables which reference people:
344:1> ALTER TABLE managers DROP CONSTRAINT managers_1466289798
344:2> go
345:1> drop table people
345:2> go
346:1>
How should one deal with the situation when the referring tables are
not part of the same metadata collection?
pjjH
341:2> sp__revtable people
341:3> go
-- Table_DDL
----------------------------------------------------------------------
CREATE TABLE people
(
person_id int identity NOT NULL,
name varchar(50) NULL,
type varchar(30) NULL
)
-----------------------------------------------------------------------------------------------------
-------------------
ALTER TABLE people ADD PRIMARY KEY CLUSTERED ( person_id)
-- FOREIGN REFERENCE
---------------------------------------
-- No Indexes found in Current Database
(return status = 0)
342:1> sp_helpconstraint people
342:2> go
name
definition created
-------------------
-------------------------------------------------------------
-------------------
managers_1466289798 managers FOREIGN KEY (person_id) REFERENCES people
(person_id) Mar 4 2009 9:12PM
people_17556708171 PRIMARY KEY INDEX ( person_id) : CLUSTERED,
FOREIGN REFERENCE Mar 4 2009 9:11PM
Total Number of Referential Constraints: 1
Details:
-- Number of references made by this table: 0
-- Number of references to this table: 1
-- Number of self references to this table: 0
Formula for Calculation:
Total Number of Referential Constraints
= Number of references made by this table
+ Number of references made to this table
- Number of self references within this table
(2 rows affected, return status = 0)
343:1> sp__revtable managers
343:2> go
-- Table_DDL
----------------------------------------------------------------------
CREATE TABLE managers
(
person_id int identity NOT NULL,
status varchar(30) NULL,
manager_name varchar(50) NULL
)
-----------------------------------------------------------------------------------------------------
-------------------
ALTER TABLE managers ADD PRIMARY KEY CLUSTERED ( person_id)
constraint_desc
-----------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
---------------------------------------------
ALTER TABLE managers ADD CONSTRAINT managers_1466289798
FOREIGN KEY (person_id) REFERENCES people(person_id)
---------------------------------------
-- No Indexes found in Current Database
(return status = 0)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---