SQL statements related to oracle table for deleting Foreign keys 1. find all the tables that reference a table with the primary key as the foreign key. PK_SRVMONITOR_SERVICE is the prim
-- Obtain the statement for disabling all foreign key constraintsSelect 'alter table ['+ B. Name +'] nocheck constraint '+ A. Name +'; 'as forbidden ConstraintFrom sysobjects A, sysobjects BWhere a. xtype = 'F' and A. parent_obj = B. ID
-- Obtain the statement for enabling all foreign
--enable or disable all foreign KEY constraints on the specified tableAlter TableTbnameNOCHECK constraint All Alter TableTbnameCHECK constraint All--View ConstraintsSelectName, is_disabled fromSys.foreign_keysOrder byname--DisabledALTER TABLETbname DISABLETRIGGERTrigname--RecoveryALTER TABLETbname ENABLETRIGGERTrigname--disable all triggers on a tableALTER TABLETbname DISABLETRIGGER All --to enable all
How do you determine in Oracle how many tables in this table have foreign key associations with them? We are mainly divided into two steps:
First step:
PRIMARY KEY constraint name for query table
SELECT * from User_constraints e where e.table_name= '
Enter the
Label:stylebloghttposar Use forsp data ---Enable or disable all foreign KEY constraints on the specified table ALTER TABLE Pub_stru NOCHECK constraint all; ALTER TABLE Pub_stru CHECK constraint all; ---Build enables or disables the specified
This morning, I learned about the use of primary and foreign keys in SQL Server and how to establish the connection between primary key and foreign key.In the afternoon, I learned how to apply the subquery inside SQL Server, and also practiced the use of functions (String fu
');View field information for a tableDESC table name; Show columns from table name;View all information for a tableShow create table table name;Add a PRIMARY KEY constraintALTER TABLE
-- Disable the specified name trigger ALTER TABLE Tbname DISABLE TRIGGER trigname-- Restore the specified name trigger ALTER TABLE Tbname ENABLE TRIGGER trigname ----enable all triggers on a table ALTER TABLE Tbname enable TRIGGER all --Disable all triggers on all tablesexec sp_msforeachtable ' ALTER
Tags: style blog ar color OS sp for strong dataDECLARE @SQLSTR VARCHAR;D eclare my_cursor Cursor--Defines the cursor for (select drop CONSTRAINT' +fk.name+ ' ; ' As Command from sys.foreign_keys FK JOIN sys.all_objects o on fk.parent_ OBJECT_ID=O.OBJECT_ID)--isolate the desired set into the cursor OPEN my_cursor; --Open cursor FETCH NEXT from my_cursor to @SQLSTR; --Reads the first row of data while @ @FETCH_STATUS = 0 BEGIN exec (@SQLSTR); --update dbo. Memberaccount SET User
--Enable or disable all foreign KEY constraints for the specified tableALTER TABLE Tbname NOCHECK constraint allALTER TABLE Tbname CHECK constraint all--View constraintsSelect Name, is_disabled from Sys.foreign_keys order by name--DisableALTER TABLE tbname DISABLE TRIGGER tr
Access to Create a Table SQL statement Create Table to set AUTOINCREMENT for Automatically increasing columns, SQL statement createtable
Access Table creation
First step: Delete the original foreign KEY constraintALTER TABLE child_table DROP FOREIGN KEY ' fk_reference_2 ';Step Two: Add a new foreign KEY constraint and increase the on DELETE C
Parse the SQL table structure information to query the data dictionary that needs to be done in the latest project including the primary and foreign keys and the self-increasing bitsCN.com. the table structure information is required. I have read a lot of queries on table st
* ** Filename: DropKeyAddKey. SQL * Description: If you want to modify the attribute of the table's primary key field, you need to delete the primary key and then recreate the primary key. The default table is the UserList Test table
Tags: sp on bs SQL MySQL CA server nbsp dateBackground:You know that when you define a foreign key, you are given an on delete ... on update ...;What is specified here is how the columns of the table should be changed to cater for the changes in the columns of the main table
Tags: column int where for main color CTS SQL refDirectly on the code: 1 SELECTOsub.name as [child table name] ,
2Fk.name as [FOREIGN Key Name] ,
3Subcol.name as [child table column name] ,
4Omain.name as [Primary Table name] ,
5M
FOREIGN KEY constraints and parameter constraintsThe Carifo table of the pubs database creates a foreign key constraint, and the primary key ID of the table is carfactory.*/Use PubsGo/*
Label:Select
a.name as constraint name,
object_name (b.parent_object_id) as foreign key table,
D.name as foreign key column,
object_name ( b.referenced_object_id) as Master, c.name as
primary key column from
Sys.foreign_keys A
inn
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.